xzw 7 月之前
父节点
当前提交
122e326d0f
共有 3 个文件被更改,包括 87 次插入26 次删除
  1. 72 17
      public/lib/potree/potree.js
  2. 1 1
      public/lib/potree/potree.js.map
  3. 14 8
      src/sdk/cover/index.js

+ 72 - 17
public/lib/potree/potree.js

@@ -22035,6 +22035,7 @@
 	    //pointcloud.getPanosBound()  
 	    viewer.updateModelBound();
 	  };
+	  var moveModelWhenLoad = false;
 	  var moveModel = e => {
 	    //根据鼠标移动的位置改变位置
 
@@ -22172,8 +22173,10 @@
 	      done(model); // 先发送成功,因为2d界面会随机执行changePosition等初始化,然后这边再将模型移到中心地面上
 
 	      if (prop.isFirstLoad) {
-	        if (model.hasLonLat) {
-	          MergeEditor.focusOn(model);
+	        if (model.hasLonLat || !moveModelWhenLoad) {
+	          setTimeout(() => {
+	            MergeEditor.focusOn(model);
+	          }, 1);
 	        } else {
 	          MergeEditor.moveBoundCenterTo(model, new Vector3(0, 0, 0));
 	        }
@@ -22188,7 +22191,7 @@
 	                  confirmPos()
 	              },1)
 	          }else{ */
-	          if (!model.hasLonLat) {
+	          if (!model.hasLonLat && moveModelWhenLoad) {
 	            viewer.addEventListener('global_mousemove', moveModel);
 	            viewer.addEventListener('global_click', confirmPos, {
 	              importance: 3
@@ -43116,6 +43119,7 @@
 	        var AB = new Vector3().subVectors(B, A);
 	        var searchIndex;
 	        while (j <= _nextIndex) {
+	          //根据APlen长度算区间
 	          var len = AB.clone().normalize().dot(new Vector3().subVectors(this.points[j + 1], A)); //在AB的投影长度
 	          if (len > APlen) {
 	            searchIndex = j;
@@ -43224,17 +43228,19 @@
 	    this.edge.geometry.dispose();
 	    if (count <= 1) {
 	      geo = voidGeometry;
+	      this.geoPoints = [];
 	    } else {
 	      if (Potree.settings.pathSmooth) {
 	        //使用曲线
-	        var line = new CatmullRomCurve3(points, false);
-	        line.UtoTMapArr = [];
-	        //window.arcLengthDivisions  && (line.arcLengthDivisions = arcLengthDivisions) //默认200,但改为1也没变化呀
-	        count = Math.max(2, Math.round(this.getTotalDistance() * 400)), points = line.getSpacedPoints(count - 1); //拆分为更密集的点
-	        this.UtoTMapArr = [];
-	        //减少点数(拐弯的部分紧凑些,直线部分宽松些)
+	        var curve = new CatmullRomCurve3(points, false);
+	        curve.UtoTMapArr = []; //用于存储 getSpacedPoints得到的点对应points的百分比对应
+	        //window.arcLengthDivisions  && (curve.arcLengthDivisions = arcLengthDivisions) //默认200,但改为1也没变化呀
+	        count = Math.max(2, Math.round(this.getTotalDistance() * 400)), points = curve.getSpacedPoints(count - 1); //拆分为更密集的点
+	        this.curve = curve;
+	        //减少点数(拐弯的部分紧凑些,直线部分宽松些)
 	        var lastVec;
 	        var newPoints = [];
+	        this.UtoTMapArr = [];
 	        for (var i = 0; i < count; i++) {
 	          var point = points[i];
 	          var last = points[i - 1];
@@ -43251,7 +43257,7 @@
 	              if (curVec.angleTo(lastVec) > 0.05) {
 	                //最小角度
 	                newPoints.push(point);
-	                this.UtoTMapArr.push(line.UtoTMapArr[i]);
+	                this.UtoTMapArr.push(curve.UtoTMapArr[i]);
 	                lastVec = curVec;
 	              }
 	            }
@@ -43259,6 +43265,7 @@
 	        }
 	        points = newPoints;
 	        count = points.length;
+	        //delete curve.UtoTMapArr 
 	      }
 	      var lastSideVec;
 	      var posArr = [],
@@ -57738,6 +57745,8 @@
 	  updateMatrixWorld(force) {
 	    //重写,只为了将root当做parent
 
+	    this.scale.set(1 / this.root.scale.x, 1 / this.root.scale.y, 1 / this.root.scale.z); //中和模型缩放。无论模型缩放如何都不能改tag大小
+
 	    this.updateMatrix();
 	    this.matrixWorld.multiplyMatrices(this.root.matrixWorld, this.matrix);
 	    var children = this.children;
@@ -59569,7 +59578,7 @@
 	        percent = easing.easeOutSine(originPercent-(1-easePercent), 1-easePercent, easePercent, easePercent)
 	    } */
 
-	    var quaternion;
+	    var quaternion, position;
 	    if (percent < 1) {
 	      //修改第二层:使用每个点的重定位的 newPointsPercents
 
@@ -59587,11 +59596,17 @@
 	      var startQuaternion = this.quaternions[this.currentIndex];
 	      quaternion = new Quaternion().copy(startQuaternion);
 	      lerp.quaternion(quaternion, endQuaternion)(progress);
+	      var endPos = this.posCurve.points[this.currentIndex + 1];
+	      var startPos = this.posCurve.points[this.currentIndex];
+	      position = new Vector3().copy(startPos);
+	      lerp.vector(position, endPos)(progress);
 	    } else {
 	      this.currentIndex = this.posCurve.points.length - 1;
-	      quaternion = math.getQuaFromPosAim(this.posCurve.points[this.currentIndex], this.targets[this.currentIndex].position);
+	      quaternion = this.quaternions[this.currentIndex];
+	      position = this.posCurve.points[this.currentIndex];
 	    }
-	    var position = this.posCurve.getPointAt(percent); // 需要this.posCurve.points.length>1 否则报错
+
+	    //position = this.posCurve.getPointAt(percent); // 需要this.posCurve.points.length>1 否则报错
 
 	    //console.log(this.currentIndex, originPercent)
 	    //缓动:
@@ -59663,7 +59678,7 @@
 	    Potree.settings.tourTestCameraMove || this.setVisible(false);
 	    var tStart,
 	      startTransitionRatio = 0.2;
-	    var startDelay = 1 / startTransitionRatio / 20; //因为缓动所以延迟开始,前面前都是at(0),使过渡到开始点位(但是依旧不能准确停在起始点,因为缓动是乘百分比有残留。所以直接平滑衔接到开始后的位置)
+	    var startDelay = 1 / startTransitionRatio / 20; //s   因为缓动所以延迟开始,前面前都是at(0),使过渡到开始点位(但是依旧不能准确停在起始点,因为缓动是乘百分比有残留。所以直接平滑衔接到开始后的位置)
 	    var hasPlayedTime = 0;
 	    var finishDelay = Potree.settings.cameraAniSmoothRatio / 60 * 3; //结束后还需要多久时间才能大致达到缓动的最终目标
 	    var hasStoppedTime = 0;
@@ -59682,11 +59697,11 @@
 	        var elapsed = (tNow - tStart) / 1000;
 	        percent = elapsed / duration + startPercent;
 	      } else {
-	        //从当前位置过渡到开始位置 
-	        percent = 0;
+	        //从当前位置过渡到开始位置  
+	        percent = 0; //因为at函数里有缓动措施,所以只需要设置位置在初始点即可。
 	        hasPlayedTime += e.delta;
 	        transitionRatio = startTransitionRatio;
-	        //console.log('延迟开始') 
+	        // console.log('延迟开始') 
 	        if (hasPlayedTime > startDelay) {
 	          tStart = performance.now();
 	        }
@@ -74189,6 +74204,42 @@
 	  }
 	};
 
+	class CameraAnimationCurve extends EventDispatcher {
+	  //沿着curve轨迹的相机动画,不指定target,因视线沿着路线
+
+	  constructor(curve, points, UtoTMapArr, duration) {
+	    //简单写
+	    super();
+	    this.viewer = viewer;
+	    this.curve = curve;
+	    this.duration = duration;
+	    this.newPointsPercents = UtoTMapArr.slice();
+	    this.posCurve = {
+	      points,
+	      pointsPercent: this.newPointsPercents,
+	      getPointAt(t) {
+	        return curve.getPointAt(t);
+	      }
+	    };
+
+	    //每个点直接朝向前面那个点
+	    this.quaternions = [];
+	    var quaternion,
+	      length = points.length;
+	    for (var i = 0; i < length - 1; i++) {
+	      quaternion = math.getQuaFromPosAim(points[i], points[i + 1]);
+	      this.quaternions.push(quaternion);
+	    }
+	    this.quaternions.push(quaternion); //最后一个点的朝向和前一个相同即可
+	  }
+	  setVisible() {}
+	  updateFrustum() {}
+	}
+	CameraAnimationCurve.prototype.play = CameraAnimation$1.prototype.play;
+	CameraAnimationCurve.prototype.at = CameraAnimation$1.prototype.at;
+	CameraAnimationCurve.prototype.set = CameraAnimation$1.prototype.set;
+	CameraAnimationCurve.prototype.pause = CameraAnimation$1.prototype.pause;
+
 	var CamAniEditor = {
 	  createAnimation(data) {
 	    var animation = new CameraAnimation$1(viewer, data.tension);
@@ -74393,6 +74444,10 @@
 	      //再把中间的缓动去除
 	    };
 	    return result;
+	  },
+	  createCurveAni(curve, points, UtoTMapArr, duration) {
+	    var ani = new CameraAnimationCurve(curve, points, UtoTMapArr, duration);
+	    return ani;
 	  }
 	};
 

文件差异内容过多而无法显示
+ 1 - 1
public/lib/potree/potree.js.map


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

@@ -751,7 +751,7 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
             map.switchStyle(type )
         }, */
         switchMapType(type){//切换成江门的卫星或标准  
-            if(window.location.href.includes('localhost:7173') ) return
+            if(window.location.href.includes('localhost:7173') || browser.urlHasValue('testMap') ) return
             console.log('switchMapType',type)
             let maximumLevel, url
             if(type == 'satellite'){
@@ -867,9 +867,8 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
 
 
         addModel(props) {
-
             let bus = props.bus = mitt()
-            //console.log('addModel',props)
+            //console.log('--addModel',props)
             props.isFirstLoad = isLocal ? props.bottom == void 0 : (props.isDynamicAdded || props.mode == 'single')  // 在编辑时用户添加的 或 展示单个模型 (props.mode='single'模型展示页, props.mode='many'融合页)
             if (props.opacity == void 0) props.opacity = 1
             if (props.type == 'obj') props.type = 'glb'
@@ -1566,7 +1565,7 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
                     path.setReverse(reverse) 
                 },
                 createAni(tension){
-                    let distance = path.getTotalDistance()
+                    let distance = path.totalLength
                     let pathPoints = path.points.map(e=>e.clone().add(new THREE.Vector3(0,0,2))) //在地面之上一定高度
                     if(path.reverse)    pathPoints.reverse() 
                     
@@ -1632,6 +1631,8 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
                     }
                     path.animation_ = viewer.modules.CamAniEditor.createAnimation(data)
                 },
+                
+                
                 play(playDone){
                     
                     let oldStates = {
@@ -1641,16 +1642,21 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
                     path.editEnable && functions.changeEditMode(false)
                     path.addOrRemovePoint && path.setAddOrRemPoint(false)
                   
-                    functions.createAni();//不传参数时路径最圆润缓和,但会脱离原路径。传参后除了拐弯都按路径,参数越大越圆润,但容易有折回的bug。 如果没有严格要求就不传参效果最佳。
+                    /* if(Potree.settings.pathSmooth){ 
+                        let curve = path.curve.clone();
+                            curve.points.forEach(e=>e.z += 2)
+                        let geoPoints = path.geoPoints.map(e=> e.clone().add(new THREE.Vector3(0,0,2)) )//height
+                        let duration = path.totalLength / 30 
+                        path.animation_ = viewer.modules.CamAniEditor.createCurveAni(curve,  geoPoints, path.UtoTMapArr, duration, 2)
+                    }else{ */
+                        functions.createAni();//不传参数时路径最圆润缓和,但会脱离原路径。传参后除了拐弯都按路径,参数越大越圆润,但容易有折回的bug。 如果没有严格要求就不传参效果最佳。
+                    //}
                     path.animation_.play() 
                     path.animation_.addEventListener('playDone', () => {
                         oldStates.editEnable && functions.changeEditMode(true)
                         oldStates.addOrRemovePoint && path.setAddOrRemPoint(true)
                         playDone && playDone() 
                     },{once:true}) 
-                    
-                    
-                    
                 },
                 pause(){
                     path.animation_.pause()