xzw 2 年之前
父节点
当前提交
1a5445ae0d

+ 17 - 6
src/custom/modules/panos/Panorama.js

@@ -283,8 +283,8 @@ class Panorama extends THREE.EventDispatcher{
         this.marker = marker 
         
         this.images360.node.add(marker)
-        Potree.settings.isTest && this.addLabel()
-        //this.addLabel2() 
+        //Potree.settings.isTest && this.addLabel()
+        this.addLabel2() 
          
         marker.addEventListener('mouseover', this.hoverOn.bind(this));  
         marker.addEventListener('mouseleave', this.hoverOff.bind(this)); 
@@ -343,15 +343,15 @@ class Panorama extends THREE.EventDispatcher{
     getMarkerMat(){
         if(!markerTex) {
             markerTex = {
-                default:texLoader.load( Potree.resourcePath+'/textures/marker.png' ),
+                //default:texLoader.load( Potree.resourcePath+'/textures/marker.png' ),
                 ring:texLoader.load( Potree.resourcePath+'/textures/marker2.png' )
             }
-            markerTex.default.anisotropy = 4 // 各向异性过滤 .防止倾斜模糊
+            //markerTex.default.anisotropy = 4 // 各向异性过滤 .防止倾斜模糊
             markerTex.ring.anisotropy = 4  
             //有可能被点云遮住吗。 
          
         } 
-        return  new DepthBasicMaterial({opacity: markerOpacitys.default, side: THREE.DoubleSide , map:markerTex.default ,transparent:true, 
+        return  new DepthBasicMaterial({opacity: markerOpacitys.default, side: THREE.DoubleSide , map:markerTex.ring/* .default */ ,transparent:true, 
             clipDistance: 2,  occlusionDistance:1,  //不能设置太短,因为过渡时深度不准确 
             useDepth:  !!(Potree.settings.useDepthTex && this.pointcloud.hasDepthTex),
             autoDepthTest:true
@@ -415,7 +415,18 @@ class Panorama extends THREE.EventDispatcher{
         this.images360.node.add(this.label);
         this.floorPosition && this.label.position.copy(this.floorPosition)
     }
-    
+    addLabel2(){  
+        if(this.label2)return
+        this.label2 = new TextSprite(Object.assign({},
+           labelProp2, {text: /* this.originID  */   parseInt(this.id)+1   }) //{text: `id:${this.id}, dataset:${this.pointcloud.name}, 4dkkId:${this.originID}`}
+        ); 
+        this.images360.node.add(this.label2);
+        this.floorPosition && this.label2.position.copy(this.floorPosition)
+        let s = 0.4
+        this.label2.scale.set(s,s,s)
+        //Potree.Utils.updateVisible(this.label2, 'notDisplay', false)
+        Potree.Utils.updateVisible(this.label2, 'panoVisi', this.visible)
+    }
      
     
     removeTextLabel(){

+ 16 - 7
src/custom/objects/TextSprite.js

@@ -38,6 +38,7 @@ export class TextSprite extends THREE.Object3D{
 		this.textColor = options.textColor || {r: 0, g: 0, b: 0, a: 1.0};
         this.borderColor = options.borderColor || { r: 0, g: 0, b: 0, a: 0.0 };
 		this.borderRadius = options.borderRadius || 6;
+        this.margin = options.margin
         if(options.text != void 0)this.setText(options.text)
         this.name = options.name 
          
@@ -93,21 +94,29 @@ export class TextSprite extends THREE.Object3D{
         //context["font-weight"] = 100; //语法与 CSS font 属性相同。
 		// get size data (height depends only on font size)
         
-        //this.text = '啊啊啊啊啊啊fag'
+        //this.text = 'f 啊啊啊 jg'
         
 		let metrics = context.measureText(this.text );
 		let textWidth = metrics.width;
-		let margin = new THREE.Vector2(this.fontsize, Math.max(  this.fontsize*0.4, 10)  );
+		let margin = this.margin || new THREE.Vector2(this.fontsize, Math.max(  this.fontsize*0.4, 10)  );
 		let spriteWidth = 2 * margin.x + textWidth + 2 * this.rectBorderThick;
 		let spriteHeight = 2 * margin.y + this.fontsize + 2 * this.rectBorderThick; 
 		context.canvas.width = spriteWidth;
 		context.canvas.height = spriteHeight;
 		context.font = this.fontWeight + ' ' + this.fontsize + 'px ' + this.fontface; 
 
+ 
+        let expand = Math.max(1, Math.pow(this.fontsize / 16, 1.3)) // 针对英文大部分在baseLine之上所以降低一点,或者可以识别当不包含jgqp时才加这个值  
          
-        let diff = 2//针对英文大部分在baseLine之上所以降低一点(metrics.fontBoundingBoxAscent - metrics.fontBoundingBoxDescent) / 2
-
-        context.textBaseline = "middle"
+        //canvas原点在左上角
+        context.textBaseline = 'alphabetic' //  "middle"  //设置文字基线。当起点y设置为0时,只有该线以下的部分被绘制出来。middle时文字显示一半(但是对该字体所有字的一半,有的字是不一定显示一半的,尤其汉字),alphabetic时是英文字母的那条基线。
+        
+        let actualHeight = metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent; // 当前文本字符串在这个字体下用的实际高度
+        
+        //文字y向距离从textBaseline向上算
+        let y = metrics.actualBoundingBoxAscent + margin.y + expand 
+        //console.log(this.text, 'y' , y, 'actualBoundingBoxAscent', metrics.actualBoundingBoxAscent,'expand',expand )
+        
         
         // border color
         context.strokeStyle = 'rgba(' + this.borderColor.r + ',' + this.borderColor.g + ',' +
@@ -125,12 +134,12 @@ export class TextSprite extends THREE.Object3D{
             context.strokeStyle = 'rgba(' + this.textBorderColor.r + ',' + this.textBorderColor.g + ',' +
                 this.textBorderColor.b + ',' + this.textBorderColor.a + ')';
             context.lineWidth = this.textBorderThick;
-            context.strokeText(this.text , this.rectBorderThick + margin.x,spriteHeight/2  + diff );
+            context.strokeText(this.text , this.rectBorderThick + margin.x, y /* spriteHeight/2  + expand */ );
         }
         
 		context.fillStyle = 'rgba(' + this.textColor.r + ',' + this.textColor.g + ',' +
 			this.textColor.b + ',' + this.textColor.a + ')';
-		context.fillText(this.text , this.rectBorderThick + margin.x, spriteHeight/2  + diff );//x,y
+		context.fillText(this.text , this.rectBorderThick + margin.x, y  /* spriteHeight/2  + expand  */);//x,y
 
 		let texture = new THREE.Texture(canvas);
 		texture.minFilter = THREE.LinearFilter;

+ 41 - 43
src/custom/objects/tool/Measure.js

@@ -38,18 +38,21 @@ const LabelDepthInfo = {
 const markerSizeInfo = {
     minSize : 25 ,  maxSize : 65,   nearBound : 0.2, farBound : 4,
 }
-const labelSizeInfo = {width2d:200}
+const labelSizeInfo = {width2d:190}
 const mainLabelProp = { 
     backgroundColor: {r: defaultColor.r*255, g: defaultColor.g*255, b: defaultColor.b*255, a:config.measure.default.opacity},
     textColor: {r: textColor.r*255, g: textColor.g*255, b: textColor.b*255, a: 1.0},
-    fontsize:16, 
-    useDepth : true ,
+    fontsize: 14, 
+    useDepth : true , borderRadius : 12, margin:{x:20,y:4},
     renderOrder : 5, pickOrder:5, 
 }
+  
+ 
+
 const subLabelProp = { 
-    backgroundColor: {r: 255, g: 255, b: 255, a:1},
-    textColor: {r: 0, g: 0, b:0, a: 1.0},
-    fontsize:14, 
+    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,
 }
 
@@ -477,8 +480,8 @@ export class Measure extends ctrlPolygon{
             //this.closed || this.edgeLabels.forEach(e=>e.elem.addClass('highLight')  )
             this.setEdgesDisplay(true, hoverObject=="screenshot")
             
-            this.areaLabel && setLabelHightState(this.areaLabel, true) 
-            this.closed || this.edgeLabels.forEach(e=>setLabelHightState(e, true)  )
+            this.areaLabel && this.setLabelHightState(this.areaLabel, true) 
+            this.closed || this.edgeLabels.forEach(e=>this.setLabelHightState(e, true)  )
               
         }else{
             this.markers.forEach(e=>this.setMarkerSelected(e, 'unhover', 'selectAll' ))
@@ -487,8 +490,8 @@ export class Measure extends ctrlPolygon{
             this.setEdgesDisplay(false, hoverObject=="screenshot")
             //this.areaLabel && this.areaLabel.elem.removeClass('highLight')
             //this.closed || this.edgeLabels.forEach(e=>e.elem.removeClass('highLight')  )
-            this.areaLabel && setLabelHightState(this.areaLabel, false) 
-            this.closed || this.edgeLabels.forEach(e=>setLabelHightState(e, false)  )
+            this.areaLabel && this.setLabelHightState(this.areaLabel, false) 
+            this.closed || this.edgeLabels.forEach(e=>this.setLabelHightState(e, false)  )
             
         }
            
@@ -503,6 +506,32 @@ export class Measure extends ctrlPolygon{
         viewer.mapViewer && viewer.mapViewer.dispatchEvent('content_changed')
     }
     
+    
+    
+    
+    setLabelHightState(label, state){ 
+        if(state){  
+            label.backgroundColor = {r:255, g:255, b:255, 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.a = config.measure.default.opacity
+            label.sprite.material.useDepth = true
+            label.textColor = {r: 255, g: 255, b: 255, a: 1} 
+            
+        }  
+        label.updateTexture()  
+    }
+
+    
+    
+    
+    
+    
+    
+    
 	removeMarker(index ){  
         super.removeMarker(index)
         
@@ -752,7 +781,7 @@ export class Measure extends ctrlPolygon{
                 transparent: !0,
                 opacity: 1,
                 map: texLoader.load(Potree.resourcePath+'/textures/pic_point32.png' ), 
-                useDepth:true ,
+                //useDepth:true ,
                 replaceColor:this.color,
                 beReplacedRed: 0.184,   //0.18431372
                 mapColorReplace:true
@@ -773,7 +802,7 @@ export class Measure extends ctrlPolygon{
                 dashSize: 0.1, 
                 gapSize: 0.02,
                 dashed: true,
-                lineWidth: config.measure.lineWidth  
+                lineWidth: 2 
             })      
         }
     
@@ -1081,37 +1110,6 @@ export class Measure extends ctrlPolygon{
 
 
 
-function setLabelHightState(label, state){
-    /* if(state){ 
-        label.backgroundColor =  {r: highlightColor.r*255, g: highlightColor.g*255, b: highlightColor.b*255, a:config.measure.highlight.opacity},
-        label.backgroundColor.a = config.measure.highlight.opacity
-        label.sprite.material.useDepth = false;
-        
-    }else{
-        label.backgroundColor = mainLabelProp.backgroundColor
-        label.backgroundColor.a = config.measure.default.opacity
-        label.sprite.material.useDepth = true
-        
-    }  */
-    
-    if(state){  
-        //label.backgroundColor =  {r: this.color[0]*255, g:  this.color[1]*255, b:  this.color[2]*255, a:config.measure.highlight.opacity},
-        label.backgroundColor.a = config.measure.highlight.opacity
-        label.sprite.material.useDepth = false;
-        
-    }else{
-        //label.backgroundColor = {r: this.color[0]*255, g:  this.color[1]*255, b:  this.color[2]*255
-        label.backgroundColor.a = config.measure.default.opacity
-        label.sprite.material.useDepth = true
-        
-    } 
-    
-    
-    label.updateTexture() 
-    //label.sprite.material.needsUpdate = true 
-}
-
-
 
 function createCircleRadiusLabel(){
 	const circleRadiusLabel = new TextSprite("");

+ 2 - 2
src/custom/settings.js

@@ -161,7 +161,7 @@ const config = {//配置参数   不可修改
         color:'#00C8AF',
         default:{
             color:"#2F8FFF",//"#00c7b2",
-            opacity:0.7
+            opacity:0.8
         },
         highlight:{
             color:"#2F8FFF",//"#00c7b2",
@@ -174,7 +174,7 @@ const config = {//配置参数   不可修改
         ,   
         backColor:'#333333',
          
-        lineWidth: 4,
+        lineWidth: 3,
        
         textColor: "#FFFFFF"
         

+ 3 - 2
src/custom/utils/transitions.js

@@ -340,7 +340,7 @@ var transitions = {
     funcs: [],
     counter: 0,
     uniqueID: 0,
-    start: function(func, duration, done, delay, ease, name, id, cancelFun, ignoreFirstFrame=true) {
+    start: function(func, duration, done, delay, ease, name, id, cancelFun, ignoreFirstFrame=true, forbitCancel) {
         return delay = delay || 0,
         this.funcs.push({
             func: func,
@@ -357,6 +357,7 @@ var transitions = {
 			cancelFun : cancelFun,   //取消时执行的函数
             updateCount:0,
             ignoreFirstFrame,
+            forbitCancel,
         }),
         func(0, 16),
         this.counter += 1,
@@ -456,7 +457,7 @@ var transitions = {
         var t = void 0 === e ? 0 : e;
 		let cancels = []
         this.funcs = this.funcs.filter(function(e) {
-			var is = e.id == t;
+			var is = e.id == t && !e.forbitCancel;
 			
 			if(is && dealCancelFun){
                 e.cancelFun && cancels.push(e.cancelFun)

+ 11 - 19
src/viewer/ExtendView.js

@@ -180,6 +180,11 @@ class ExtendView extends View {
     setView( info = {}){
         // position, target, duration = 0, callback = null, onUpdate = null, Easing='', cancelFun
         this.cancelFlying()
+        if(this.isFlying()){
+            if(info.cancelFun)info.cancelFun()
+            return ;//取消失败
+        }
+        
         let posWaitDone,  rotWaitDone , dir
         
         let posDone = ()=>{
@@ -271,7 +276,7 @@ class ExtendView extends View {
                     } 
                     posWaitDone = false 
                     info.cancelFun && info.cancelFun()
-                }, info.ignoreFirstFrame);  
+                }, info.ignoreFirstFrame,info.forbitCancel);  
             } 
             
             if(endQuaternion || endYaw != void 0){
@@ -293,26 +298,13 @@ class ExtendView extends View {
                     //中途取消
                     rotWaitDone = false
                     info.cancelFun && info.cancelFun()
-                }, info.ignoreFirstFrame); 
+                }, info.ignoreFirstFrame, info.forbitCancel); 
                   
             }      
          
             
             
-           /*  transitions.start(lerp.vector(this.position, endPosition, (pos, progress)=>{
-				let t = progress 
- 
-                if(endQuaternion){  
-                    let quaternion = (new THREE.Quaternion()).copy(startQuaternion) 
-                    lerp.quaternion(quaternion, endQuaternion)(progress),
-                    this.rotation = new THREE.Euler().setFromQuaternion(quaternion)
-                }
-                this.restrictPos()
-                //console.log('setView flying')             
- 
-                info.onUpdate && info.onUpdate(t)//add
-            }), info.duration, done, 0, info.Easing ? easing[info.Easing] : easing.easeInOutSine  ,null, this.LookTransition, info.cancelFun); //easeInOutQuad
-            */
+           
 
         } 
 
@@ -433,17 +425,17 @@ class ExtendView extends View {
         }
         
         let callback = info.callback
-        info.callback = ()=>{ 
+        info.callback = info.cancelFun = ()=>{ 
             viewport.camera = info.endCamera  
             viewer.scene.measurements.forEach((e)=>{ 
                 Potree.Utils.updateVisible(e, 'tranCamera', true) 
             }) 
             viewer.dispatchEvent({type:'camera_changed', viewport:viewer.mainViewport, changeInfo:{}})//update sprite
-       
+            
             
             callback && callback()
         } 
-        
+        info.forbitCancel = true 
         
         viewer.scene.measurements.forEach((e)=>{
             Potree.Utils.updateVisible(e, 'tranCamera', false) //含sprite且实时更新size的都要隐藏

+ 22 - 15
src/viewer/NavigationCube.js

@@ -568,24 +568,31 @@ class NavigationCube{
                 
                 //不过平板无hover事件
                 faceMesh.addEventListener('mouseover', (e)=>{
-                    if(navCubeViewer.changingView)return
+                    if(viewer.mainViewport.view.isFlying())return
                     faceMesh.material.uniforms.faceColor.value.set(Colors.blue)
                     //console.log('变', name)
                     navCubeViewer.dispatchEvent('content_changed')
                 });
                 faceMesh.addEventListener('mouseleave', (e)=>{
-                    if(navCubeViewer.changingView)return
+                    if(viewer.mainViewport.view.isFlying())return
                     faceMesh.material.uniforms.faceColor.value.set(Colors.black)
                     //console.log('回', name)
                     navCubeViewer.dispatchEvent('content_changed')
                 });
                 
                 faceMesh.addEventListener('click', (e)=>{  
-                    if(navCubeViewer.switchView('ortho', directions[name] ,   ()=>{ 
+                    /* if(navCubeViewer.switchView('ortho', directions[name] ,   ()=>{ 
                         faceMesh.material.uniforms.faceColor.value.set(Colors.black)
                     }) ){
                         faceMesh.material.uniforms.faceColor.value.set(Colors.blue) 
-                    }
+                    } */
+                    
+                    
+                    if(viewer.mainViewport.view.isFlying())return
+                    navCubeViewer.switchView('ortho', directions[name] ,   ()=>{ 
+                        faceMesh.material.uniforms.faceColor.value.set(Colors.black)
+                    }) 
+                    faceMesh.material.uniforms.faceColor.value.set(Colors.blue) 
                 }); 
                  
                 if(name == 'Top'){
@@ -818,7 +825,7 @@ class NavCubeViewer extends ViewerBase{
         }
     } */
     switchView(type, {yaw, pitch, dir}={}, done){
-        if(this.changingView)return
+        if(viewer.mainViewport.view.isFlying())return
         let view = viewer.mainViewport.view
         this.lastView = view.clone()
         if(viewer.mainViewport.camera.type == 'OrthographicCamera'){
@@ -856,11 +863,11 @@ class NavCubeViewer extends ViewerBase{
                 endPitch: pitch, endYaw: yaw , dir,  startCamera, endCamera
             }).promise.done(()=>{  
                 //viewer.dispatchEvent('reachTopView')
-                this.changingView = false
+                 
                 done && done()
                 navCubeViewer.dispatchEvent('content_changed')
             })
-            this.changingView = true
+             
         }else{
             
             if(viewer.mainViewport.camera == viewer.scene.cameraO){
@@ -886,14 +893,14 @@ class NavCubeViewer extends ViewerBase{
                 view.tranCamera(viewer.mainViewport,  { position ,   
                     callback:()=>{ 
                         done && done()
-                        this.changingView = false
+                         
                     }, startCamera:viewer.scene.cameraO, endCamera:viewer.scene.cameraP, midCamera:viewer.scene.cameraBasic
                 }, 500)
-                this.changingView = true
+                 
                 
             } 
         }
-        return this.changingView
+         
     } 
     
     
@@ -901,10 +908,10 @@ class NavCubeViewer extends ViewerBase{
     
     
     switchView2(viewInfo){ //直接输入view改变
-        if(this.changingView)return
+        
         let view = viewer.mainViewport.view
         let startCamera, endCamera 
-        this.changingView = true
+     
     
         if(viewInfo.isOrtho){
             if(viewer.mainViewport.camera != viewer.scene.cameraO){ 
@@ -916,7 +923,7 @@ class NavCubeViewer extends ViewerBase{
                 view.moveOrthoCamera(viewer.mainViewport,  {endPosition:viewInfo.position,
                     endPitch: viewInfo.pitch, endYaw: viewInfo.yaw ,  zoom: viewInfo.zoom, 
                     callback:()=>{ 
-                        this.changingView = false
+                        
                     }, 
                 }, 500)
             }
@@ -930,7 +937,7 @@ class NavCubeViewer extends ViewerBase{
                     endPitch: viewInfo.pitch, endYaw: viewInfo.yaw ,   
                     startCamera,  endCamera,            
                     callback:()=>{ 
-                        this.changingView = false
+                       
                     }, 
                 }, 500)
             }
@@ -943,7 +950,7 @@ class NavCubeViewer extends ViewerBase{
                 endPitch: viewInfo.pitch, endYaw: viewInfo.yaw ,   
                 startCamera,   endCamera,   midCamera:viewer.scene.cameraBasic ,            
                 callback:()=>{ 
-                    this.changingView = false
+                   
                 }, 
             }, 500)
         } 

+ 10 - 12
改bug的历史.txt

@@ -1,3 +1,12 @@
+
+
+
+
+
+
+
+
+
 2023.2.17
 
 现象:转动过程中,面对相同的一块点云,有时候很流畅,有时候反向再转回去超级卡,但numVisiblePoints并无增加。
@@ -43,18 +52,7 @@ NAME                  |    MIN | MEDIAN |    MAX |    AVE | SAMPLES
 
 
 
-
-
-
-
-
-
-
-
-
-
-
-
+ 
 
 
 2023.2.7