xzw 4 月之前
父節點
當前提交
857d786586
共有 3 個文件被更改,包括 97 次插入23 次删除
  1. 88 21
      public/lib/potree/potree.js
  2. 1 1
      public/lib/potree/potree.js.map
  3. 8 1
      src/sdk/cover/index.js

+ 88 - 21
public/lib/potree/potree.js

@@ -7826,12 +7826,11 @@
 	  },
 	  getFootPoint: function getFootPoint(oldPos, p1, p2, restricInline) {
 	    //找oldPos在线段p1, p2上的垂足
-	    /* if(isWorld){//输出全局坐标 需要考虑meshGroup.position
-	    	p1 = p1.clone();
-	    	p2 = p2.clone();
-	    	p1.y += mainDesign.meshGroup.position.y;
-	    	p2.y += mainDesign.meshGroup.position.y;
-	    } */
+	    /*  
+	          let p1o = new THREE.Vector3().subVectors(o,p1)
+	          let p1p2 =  new THREE.Vector3().subVectors(p2,p1)
+	          let p1F = p1o.projectOnVector(p1p2)
+	          return new THREE.Vector3().addVectors(p1,p1F) */ //也可以这样
 	    if (p1.equals(p2)) return p1.clone();
 	    var op1 = oldPos.clone().sub(p1);
 	    var p1p2 = p1.clone().sub(p2);
@@ -60932,7 +60931,7 @@
 	};
 	var planeGeo$3 = new PlaneBufferGeometry(1, 1);
 	var texLoader$8 = new TextureLoader();
-	var lineMat;
+	var lineMat, dragPointMat;
 	var defaultLineLength = 1;
 	var defaultSpotScale = 0.35;
 	var titleHeight = {
@@ -60951,9 +60950,15 @@
 	    this.lineLength = o.lineLength != void 0 ? o.lineLength : defaultLineLength;
 	    this.position.copy(o.position);
 	    this.normal = o.normal != void 0 ? o.normal : new Vector3(0, 0, 1);
-	    this.dragEnable = true;
 	    this.build(o);
 	    this.bindEvent();
+	    this.dragEnable = true;
+	  }
+	  set dragEnable(state) {
+	    this.lineDragPoint.visible = state;
+	  }
+	  get dragEnable() {
+	    return this.lineDragPoint.visible;
 	  }
 	  build(o) {
 	    lineMat || (lineMat = LineDraw.createFatLineMat(Object.assign({}, depthMatProp, {
@@ -60965,6 +60970,7 @@
 	    this.spot = new Mesh(planeGeo$3, new DepthBasicMaterial(Object.assign({}, depthMatProp, {
 	      transparent: true
 	    })));
+	    this.spot.name = 'spot';
 	    this.spot.scale.set(defaultSpotScale, defaultSpotScale, defaultSpotScale);
 	    this.spot.renderOrder = this.spot.pickOrder = Potree.config.renderOrders.tag.spot;
 	    Potree.settings.isOfficial || this.changeMap(Potree.resourcePath + '/textures/spot_default.png');
@@ -61013,6 +61019,30 @@
 	    this.add(group);
 	    this.add(this.line);
 	    viewer.tags.add(this);
+	    if (!dragPointMat) {
+	      var map = texLoader$8.load(Potree.resourcePath + '/textures/whiteCircle.png', () => {});
+	      dragPointMat = {
+	        default: new MeshBasicMaterial({
+	          map,
+	          transparent: true,
+	          color: '#0fe',
+	          opacity: 0,
+	          depthTest: false
+	        }),
+	        hover: new MeshBasicMaterial({
+	          map,
+	          transparent: true,
+	          color: '#0fe',
+	          opacity: 0.4,
+	          depthTest: false
+	        })
+	      };
+	    }
+	    this.lineDragPoint = new Mesh(planeGeo$3, dragPointMat.default); //修改线高度时出现的小圆点
+	    this.lineDragPoint.scale.set(0.2, 0.2, 0.2);
+	    this.lineDragPoint.name = 'lineDragPoint';
+	    this.lineDragPoint.renderOrder = this.lineDragPoint.pickOrder = Potree.config.renderOrders.tag.spot + 3;
+	    group.add(this.lineDragPoint);
 	    this.updatePose();
 	  }
 	  bindEvent() {
@@ -61038,18 +61068,18 @@
 	          });
 	        }
 	      };
-	      [this.line, this.spot].forEach(e => e.addEventListener('mousemove', e => {
-	        hoverState[e.target.name == 'tagLine' ? 'line' : 'spot'] = 1;
-	        if (this.dragEnable && viewer.inputHandler.intersect) {
+	      [this.line, this.spot, this.lineDragPoint].forEach(e => e.addEventListener('mousemove', e => {
+	        hoverState[e.target.name] = 1;
+	        if (this.dragEnable && (viewer.inputHandler.intersect || hoverState['lineDragPoint'])) {
 	          //能拖拽时
 	          setCursor('hoverGrab', 'add');
 	        } else {
 	          setCursor('hoverGrab', 'remove');
 	        }
 	      }));
-	      [this.line, this.spot].forEach(e => e.addEventListener('mouseleave', e => {
-	        hoverState[e.target.name == 'tagLine' ? 'line' : 'spot'] = 0;
-	        if (!hoverState.line && !hoverState.spot) {
+	      [this.line, this.spot, this.lineDragPoint].forEach(e => e.addEventListener('mouseleave', e => {
+	        hoverState[e.target.name] = 0;
+	        if (!Object.values(hoverState).some(e => e)) {
 	          //都没hover才取消    
 	          setCursor('hoverGrab', 'remove');
 	        }
@@ -61057,16 +61087,20 @@
 	            this.dispatchEvent('mouseleave')
 	        } */
 	      }));
-	      [this.line, this.spot].forEach(e => e.addEventListener('drag', e => {
+	      [this.line, this.spot, this.lineDragPoint].forEach(e => e.addEventListener('drag', e => {
 	        if (this.dragEnable && cursor.grabbing) {
-	          var info = viewer.tagTool.getPoseByIntersect(e);
-	          info && this.changePos(info);
+	          if (e.target.name == 'lineDragPoint') {
+	            this.dragLineLen(e);
+	          } else {
+	            var info = viewer.tagTool.getPoseByIntersect(e);
+	            info && this.changePos(info);
+	          }
 	        }
 	      }));
-	      [this.line, this.spot].forEach(e => e.addEventListener('startDragging', e => {
-	        this.dragEnable && viewer.inputHandler.intersect && setCursor('grabbing', 'add');
+	      [this.line, this.spot, this.lineDragPoint].forEach(e => e.addEventListener('startDragging', e => {
+	        this.dragEnable && (viewer.inputHandler.intersect || e.target.name == 'lineDragPoint') && setCursor('grabbing', 'add');
 	      }));
-	      [this.line, this.spot].forEach(e => e.addEventListener('drop', e => {
+	      [this.line, this.spot, this.lineDragPoint].forEach(e => e.addEventListener('drop', e => {
 	        this.dragEnable && setCursor('grabbing', 'remove');
 	      }));
 	      //拖拽线来移动。虽然理想方式是拟真,拖拽时不改变在线上的位置,使之平移,但仔细想想似乎办不到。因为墙面normal是不固定的,尤其在交界处难以确定。不知鼠标在空中的位置,即使是平行镜头移动也无法满足所有情况。matterport是加了底座,移动也是改变底座中心。
@@ -61093,6 +61127,25 @@
 	    this.titleLabel.sprite.addEventListener('spriteUpdated', () => {
 	      this.updateDepthParams();
 	    });
+
+	    //-----------set line length 
+
+	    // CursorDeal
+	    this.lineDragPoint.addEventListener('mouseover', e => {
+	      this.lineDragPoint.material = dragPointMat.hover;
+	      this.spot.material.opacity = 0.5;
+	      CursorDeal.add('hoverGrab');
+	    });
+	    this.lineDragPoint.addEventListener('mouseleave', e => {
+	      this.lineDragPoint.material = dragPointMat.default;
+	      this.spot.material.opacity = 1;
+	    });
+	    /* this.lineDragPoint.addEventListener('drag',(e)=>{
+	        
+	    })
+	    this.lineDragPoint.addEventListener('drop',(e)=>{
+	        
+	    }) */
 	  }
 	  updateDepthParams() {
 	    //为了避免热点嵌入墙壁,实时根据其大小更新材质系数。 但是在倾斜的角度看由于遮挡距离很大肯定会嵌入的
@@ -61122,9 +61175,23 @@
 	    viewer.dispatchEvent('content_changed');
 	  }
 	  changeLineLen(len) {
-	    this.lineLength = len;
+	    this.lineLength = parseFloat(len);
 	    this.updatePose();
 	  }
+	  dragLineLen(e) {
+	    //拖拽线的顶端修改线长度
+	    var endPos = this.normal.clone().multiplyScalar(this.lineLength).applyMatrix4(this.matrixWorld);
+	    var normal = this.normal.clone().applyQuaternion(this.getWorldQuaternion(new Quaternion()));
+	    var projected = endPos.clone().project(e.drag.dragViewport.camera);
+	    projected.x = e.pointer.x;
+	    projected.y = e.pointer.y;
+	    var unprojected = projected.clone().unproject(e.drag.dragViewport.camera);
+	    var moveVec = new Vector3().subVectors(unprojected, endPos);
+	    moveVec = moveVec.projectOnVector(normal);
+	    var newLength = Math.max(0, this.lineLength + moveVec.dot(normal));
+	    console.log(moveVec, newLength);
+	    this.changeLineLen(newLength);
+	  }
 	  changePos(info) {
 	    //注:onMesh时在非平地上拖拽,热点旋转会一直变 
 	    this.position.copy(info.position);

File diff suppressed because it is too large
+ 1 - 1
public/lib/potree/potree.js.map


+ 8 - 1
src/sdk/cover/index.js

@@ -1814,6 +1814,10 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
                     switchSelect(e.state)
                     bus.emit('focus', e.state) 
                 })
+                
+                path.addEventListener('dragLineLen',(e)=>{ 
+                    bus.emit('changeLineHeight', path.lineLength) 
+                })
                  
             }
             let funs = getMeasureFunction(path, bus) 
@@ -1877,6 +1881,7 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
                 changeLine({width,color,altitudeAboveGround}){
                     path.setPathWidth(width)
                     path.setColor(color)
+                    path.setLineLength(altitudeAboveGround)
                 },
                 changeVisibilityRange(far){//设置消失距离 
                     path.setFadeFar(far== -1 ? 0 : far) 
@@ -2072,7 +2077,9 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
                     pos: tag.position.clone()
                 })
             })
-            
+            tag.addEventListener('dragLineLen',(e)=>{ 
+                bus.emit('changeLineHeight', tag.lineLength) 
+            })
             
             
             tag.functions = {