xzw 4 months ago
parent
commit
5e95d5127d
3 changed files with 34 additions and 18 deletions
  1. 27 10
      public/lib/potree/potree.js
  2. 1 1
      public/lib/potree/potree.js.map
  3. 6 7
      src/sdk/cover/index.js

+ 27 - 10
public/lib/potree/potree.js

@@ -6595,8 +6595,10 @@
 	    }
 	    return get(url);
 	  },
-	  getBoundPoints(bound) {
-	    return [new Vector3(bound.min.x, bound.min.y, bound.min.z), new Vector3(bound.min.x, bound.min.y, bound.max.z), new Vector3(bound.min.x, bound.max.y, bound.min.z), new Vector3(bound.max.x, bound.min.y, bound.min.z), new Vector3(bound.max.x, bound.max.y, bound.min.z), new Vector3(bound.max.x, bound.min.y, bound.max.z), new Vector3(bound.min.x, bound.max.y, bound.max.z), new Vector3(bound.max.x, bound.max.y, bound.max.z)];
+	  getBoundPoints(bound, matrixWorld) {
+	    var points = [new Vector3(bound.min.x, bound.min.y, bound.min.z), new Vector3(bound.min.x, bound.min.y, bound.max.z), new Vector3(bound.min.x, bound.max.y, bound.min.z), new Vector3(bound.max.x, bound.min.y, bound.min.z), new Vector3(bound.max.x, bound.max.y, bound.min.z), new Vector3(bound.max.x, bound.min.y, bound.max.z), new Vector3(bound.min.x, bound.max.y, bound.max.z), new Vector3(bound.max.x, bound.max.y, bound.max.z)];
+	    matrixWorld && points.forEach(e => e.applyMatrix4(matrixWorld));
+	    return points;
 	  },
 	  //---------------------------
 
@@ -53457,7 +53459,7 @@
 	    this._visible = true;
 	    //this.showVolumeLabel = true;
 	    this._modifiable = args.modifiable || true;
-	    {
+	    if (!args.noPointerEvent) {
 	      // event listeners
 	      this.addEventListener('select', e => {
 	        //console.log('select')
@@ -53566,7 +53568,8 @@
 	      color: colors[this.clipTask],
 	      opacity: LineOpacity.default,
 	      lineWidth: 1,
-	      dontAlwaysSeen: true
+	      dontAlwaysSeen: true,
+	      autoDepthTest: true
 	    });
 
 	    // this.frame.mode = THREE.Lines;
@@ -71987,6 +71990,7 @@
 
 	  // Detatch from object
 	  this.detach = function () {
+	    console.warn('detach');
 	    this.object = undefined;
 	    this.axis = null;
 	    //Config.keyCon = true;//add
@@ -72307,6 +72311,7 @@
 	      }
 	      //add:
 
+	      this.options.minScale && object.scale.max(this.options.minScale);
 	      object.dispatchEvent({
 	        type: "scale_changed",
 	        byControl: true
@@ -75784,6 +75789,12 @@
 	    this.boxHelper = new Box3Helper$1(new Box3(new Vector3(-0.5, -0.5, -0.5), new Vector3(0.5, 0.5, 0.5)));
 	    viewer.scene.scene.add(this.boxHelper);
 	    Potree.Utils.updateVisible(this.boxHelper, 'unselect', false);
+	    this.boxHelper.material.opacity = 0.7;
+	    var boxHelper2 = new Box3Helper$1(new Box3(new Vector3(-0.5, -0.5, -0.5), new Vector3(0.5, 0.5, 0.5)));
+	    boxHelper2.material.opacity = 0.3;
+	    boxHelper2.material.transparent = true, boxHelper2.material.depthTest = false;
+	    this.boxHelper.add(boxHelper2); //透明一点的boxHelper */
+
 	    this.lastMemoryState = {};
 	    this.history = new History({
 	      applyData: data => {
@@ -75837,7 +75848,8 @@
 	    {
 	      this.transformControls = new TransformControls(viewer.mainViewport.camera, viewer.renderArea, {
 	        //dontHideWhenFaceCamera: true,
-	        showRotXYZE: true
+	        showRotXYZE: true,
+	        minScale: new Vector3(0.00001, 0.00001, 0.00001)
 	      });
 	      //this.transformControls.space = 'local'//为了在当前方向上平移
 	      this.transformControls.setSize(1.5);
@@ -76311,20 +76323,24 @@
 	    if (!(objects instanceof Array)) {
 	      objects = [objects];
 	    }
+	    var points = []; //用points会更近一些准一点
 	    var boundingBox = new Box3();
 	    objects.forEach(object => {
-	      boundingBox.union(object.boundingBox.clone().applyMatrix4(object.matrixWorld));
+	      points.push(...Common$1.getBoundPoints(object.boundingBox, object.matrixWorld));
+	      boundingBox.union(object.bound /* object.boundingBox.clone().applyMatrix4(object.matrixWorld) */);
 	    });
 	    var len = boundingBox.getSize(new Vector3()).length();
 	    Potree.settings.cameraFar = Math.max(Potree.settings.cameraFar, len * 3);
 	    if (focus) {
 	      viewer.focusOnObject({
-	        boundingBox
+	        boundingBox,
+	        points
 	      }, 'boundingBox', duration, {
+	        boundScale: 0.8,
 	        dontLookUp,
 	        dontChangeCamDir: dir ? false : true,
 	        dir
-	      });
+	      }); //boundScale小一点离近一点
 	    } else {
 	      /* 
 	      let position = viewer.inputHandler.intersect ? viewer.inputHandler.intersect.location : boundingBox.getCenter(new THREE.Vector3)
@@ -84854,7 +84870,8 @@
 	        var distance = o.position.distanceTo(o.CamTarget);
 	        //if(distance < minRadius) minRadius = distance * 0.5 //融合页面当focus一个很小的物体时,需要将minRadius也调小
 	        this.minRadius = Math.min(standartMinRadius, distance * 0.5);
-	        //console.log('focus dis', distance) 
+	        this.maxRadius = Math.max(this.maxRadius, distance);
+	        console.log('focusOnObject radius ', viewer.mainViewport.view.radius);
 	      }
 	    });
 	  }
@@ -84921,7 +84938,7 @@
 	    var distance = MathUtils.clamp(dis, 0.8 * object.scale.x, Math.max(len * 0.1, 3 * object.scale.x));
 	    this.minRadius = Math.min(distance, standartMinRadius);
 	    this.maxRadius = dis * 2;
-	    //console.log('maxRadius hasIntersect',   this.maxRadius)
+	    //console.log('maxRadius hasIntersect', this.maxRadius)
 	    return distance;
 	  }
 	  updateRadius(type) {

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


+ 6 - 7
src/sdk/cover/index.js

@@ -583,7 +583,7 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
 
         getScreenByPosition(pos3d, modelId, canShelter/* , disToCameraLimit */) {//通过模型局部坐标获取屏幕坐标 
 
-            //console.log('getScreenByPoint ')
+            //console.log('getScreenByPoint ', pos3d.toArray())
             let isLocal = modelId != void 0
             pos3d = new THREE.Vector3().copy(pos3d)
             let worldPos = isLocal ? Potree.Utils.datasetPosTransform({ fromDataset: true, datasetId: modelId, position: pos3d }) : pos3d
@@ -1183,7 +1183,7 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
                     }
                 },
                 changeSelect(state) {
-                    //console.error('select', state)
+                    //console.error('select', model?.name, state)
                     if (model) { 
                         //window.test111 && result.putInFrontOfCam()
                         
@@ -1695,9 +1695,8 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
                            
                             if(!model.visible)return null
                          
-                            let boundPoints = Potree.Common.getBoundPoints(model.boundingBox)
-                            boundPoints.forEach(e=>{
-                                e.applyMatrix4(model.matrixWorld) 
+                            let boundPoints = Potree.Common.getBoundPoints(model.boundingBox, model.modelMatrix)
+                            boundPoints.forEach(e=>{ 
                                 e.pos2d = Potree.Utils.getPos2d(e, viewer.mainViewport , viewer.renderArea, viewer.renderer  )
                             }) 
                             boundPoints = boundPoints.filter(e=>e.pos2d.inSight && e.pos2d.trueSide )
@@ -2243,7 +2242,7 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
                     if(!tag.parent)return new THREE.Vector3
                      tag.titleLabel.sprite.update()
                     let pos = tag.onMesh ? tag.position : tag.titleLabel.parent.position.clone().applyMatrix4(tag.matrixWorld).applyMatrix4(tag.root.matrixWorld.clone().invert()) 
-                    //console.log(props.title, 'getImageCenter', pos.toArray(), tag.lineLength)
+                    console.log(props.title, 'getImageCenter', pos.toArray(), tag.lineLength)
                     return  pos
                      
                 },
@@ -2472,7 +2471,7 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
         }
         
         if(near != viewer.mainViewport.camera.near){
-            console.log('updateNear',near)
+            //console.log('updateNear',near)
             viewer.mainViewport.camera.near = near
             viewer.mainViewport.camera.updateProjectionMatrix()
             viewer.dispatchEvent('content_changed')