xzw il y a 5 mois
Parent
commit
5e95d5127d
3 fichiers modifiés avec 34 ajouts et 18 suppressions
  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);
 	    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._visible = true;
 	    //this.showVolumeLabel = true;
 	    //this.showVolumeLabel = true;
 	    this._modifiable = args.modifiable || true;
 	    this._modifiable = args.modifiable || true;
-	    {
+	    if (!args.noPointerEvent) {
 	      // event listeners
 	      // event listeners
 	      this.addEventListener('select', e => {
 	      this.addEventListener('select', e => {
 	        //console.log('select')
 	        //console.log('select')
@@ -53566,7 +53568,8 @@
 	      color: colors[this.clipTask],
 	      color: colors[this.clipTask],
 	      opacity: LineOpacity.default,
 	      opacity: LineOpacity.default,
 	      lineWidth: 1,
 	      lineWidth: 1,
-	      dontAlwaysSeen: true
+	      dontAlwaysSeen: true,
+	      autoDepthTest: true
 	    });
 	    });
 
 
 	    // this.frame.mode = THREE.Lines;
 	    // this.frame.mode = THREE.Lines;
@@ -71987,6 +71990,7 @@
 
 
 	  // Detatch from object
 	  // Detatch from object
 	  this.detach = function () {
 	  this.detach = function () {
+	    console.warn('detach');
 	    this.object = undefined;
 	    this.object = undefined;
 	    this.axis = null;
 	    this.axis = null;
 	    //Config.keyCon = true;//add
 	    //Config.keyCon = true;//add
@@ -72307,6 +72311,7 @@
 	      }
 	      }
 	      //add:
 	      //add:
 
 
+	      this.options.minScale && object.scale.max(this.options.minScale);
 	      object.dispatchEvent({
 	      object.dispatchEvent({
 	        type: "scale_changed",
 	        type: "scale_changed",
 	        byControl: true
 	        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)));
 	    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);
 	    viewer.scene.scene.add(this.boxHelper);
 	    Potree.Utils.updateVisible(this.boxHelper, 'unselect', false);
 	    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.lastMemoryState = {};
 	    this.history = new History({
 	    this.history = new History({
 	      applyData: data => {
 	      applyData: data => {
@@ -75837,7 +75848,8 @@
 	    {
 	    {
 	      this.transformControls = new TransformControls(viewer.mainViewport.camera, viewer.renderArea, {
 	      this.transformControls = new TransformControls(viewer.mainViewport.camera, viewer.renderArea, {
 	        //dontHideWhenFaceCamera: true,
 	        //dontHideWhenFaceCamera: true,
-	        showRotXYZE: true
+	        showRotXYZE: true,
+	        minScale: new Vector3(0.00001, 0.00001, 0.00001)
 	      });
 	      });
 	      //this.transformControls.space = 'local'//为了在当前方向上平移
 	      //this.transformControls.space = 'local'//为了在当前方向上平移
 	      this.transformControls.setSize(1.5);
 	      this.transformControls.setSize(1.5);
@@ -76311,20 +76323,24 @@
 	    if (!(objects instanceof Array)) {
 	    if (!(objects instanceof Array)) {
 	      objects = [objects];
 	      objects = [objects];
 	    }
 	    }
+	    var points = []; //用points会更近一些准一点
 	    var boundingBox = new Box3();
 	    var boundingBox = new Box3();
 	    objects.forEach(object => {
 	    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();
 	    var len = boundingBox.getSize(new Vector3()).length();
 	    Potree.settings.cameraFar = Math.max(Potree.settings.cameraFar, len * 3);
 	    Potree.settings.cameraFar = Math.max(Potree.settings.cameraFar, len * 3);
 	    if (focus) {
 	    if (focus) {
 	      viewer.focusOnObject({
 	      viewer.focusOnObject({
-	        boundingBox
+	        boundingBox,
+	        points
 	      }, 'boundingBox', duration, {
 	      }, 'boundingBox', duration, {
+	        boundScale: 0.8,
 	        dontLookUp,
 	        dontLookUp,
 	        dontChangeCamDir: dir ? false : true,
 	        dontChangeCamDir: dir ? false : true,
 	        dir
 	        dir
-	      });
+	      }); //boundScale小一点离近一点
 	    } else {
 	    } else {
 	      /* 
 	      /* 
 	      let position = viewer.inputHandler.intersect ? viewer.inputHandler.intersect.location : boundingBox.getCenter(new THREE.Vector3)
 	      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);
 	        var distance = o.position.distanceTo(o.CamTarget);
 	        //if(distance < minRadius) minRadius = distance * 0.5 //融合页面当focus一个很小的物体时,需要将minRadius也调小
 	        //if(distance < minRadius) minRadius = distance * 0.5 //融合页面当focus一个很小的物体时,需要将minRadius也调小
 	        this.minRadius = Math.min(standartMinRadius, distance * 0.5);
 	        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));
 	    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.minRadius = Math.min(distance, standartMinRadius);
 	    this.maxRadius = dis * 2;
 	    this.maxRadius = dis * 2;
-	    //console.log('maxRadius hasIntersect',   this.maxRadius)
+	    //console.log('maxRadius hasIntersect', this.maxRadius)
 	    return distance;
 	    return distance;
 	  }
 	  }
 	  updateRadius(type) {
 	  updateRadius(type) {

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