xzw 4 tháng trước cách đây
mục cha
commit
c9112bd1cd
3 tập tin đã thay đổi với 48 bổ sung108 xóa
  1. 21 87
      public/lib/potree/potree.js
  2. 1 1
      public/lib/potree/potree.js.map
  3. 26 20
      src/sdk/cover/index.js

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

@@ -62297,7 +62297,7 @@
 	    this.cylinderNear = data.data.near || 0.03;
 	    this.cylinderFar = data.data.far || 3;
 	    model.add(this);
-	    this.video = videoPlayer.getVideo(data.video, this);
+	    this.video = videoPlayer.getVideo(this.getVideoSrc(), this);
 	    if (data.video) {
 	      //console.error('createVideo', this.videoSrc,   this.sid)
 	      /* this.video.onloadedmetadata = () => {
@@ -62424,9 +62424,9 @@
 	      this.position.copy(Potree.Utils.tran4dkkVecInModel(this.position, model));
 
 	      // target的优先级大于rotation
-	      if (data.target) {
+	      if (data.data.target) {
 	        this.target = Potree.Utils.tran4dkkVecInModel(data.data.target, model);
-	        this.lookAt(data.target);
+	        this.lookAt(data.data.target);
 	      } else {
 	        data.data.rotation && this.quaternion.setFromEuler(data.data.rotation);
 	        this.target = new Vector3(0, 0, -1).applyQuaternion(this.quaternion).add(this.position);
@@ -62458,6 +62458,15 @@
 	    Potree.Utils.setObjectLayers(this.cylinder.bottom, 'monitor');
 	    this.cameraModel && Potree.Utils.setObjectLayers(this.cameraModel, 'sceneObjects');
 	  }
+	  getVideoSrc() {
+	    if (this.data.urlType === 2) {
+	      var a = this.parent.props.raw.surveillancePath.split('/');
+	      a.pop();
+	      return a.join('/') + '/' + data.fileName;
+	    } else {
+	      return data.playUrl;
+	    }
+	  }
 	  modelLoaded() {
 	    this.cameraModel = cameraModel.clone();
 	    this.cameraModel.material = cameraModel.material.clone();
@@ -62490,6 +62499,7 @@
 	    this.video.pause(); //先显示出画面
 	    setTimeout(() => {
 	      viewer.mainViewport.cameraLayers = ['monitor']; //hide others 
+	      viewer.scene.monitors.forEach(e => Potree.Utils.updateVisible(e, 'watch', e == this));
 	    }, 800);
 	    viewer.mainViewport.view.setRotMode('free');
 	    viewer.mainViewport.view.setView({
@@ -62517,11 +62527,13 @@
 	    this.cameraModel.material.color.copy(normalColor);
 	    viewer.mainViewport.view.cancelFlying();
 	    viewer.mainViewport.cameraLayers = null;
+	    viewer.scene.monitors.forEach(e => Potree.Utils.updateVisible(e, 'watch', true));
 	    this.video.pause();
 	    viewer.mainViewport.view.setView({
 	      position: this.oldState.position,
 	      quaternion: this.oldState.quaternion,
 	      onUpdate: percent => {
+	        console.log(viewer.mainViewport.view.quaternion.toArray());
 	        camera.fov = this.fov * (1 - percent) + this.oldState.fov * percent;
 	        camera.updateProjectionMatrix();
 	      },
@@ -62688,7 +62700,7 @@
 	  // 横滚角
 	  setRoll(angle) {
 	    this.roll = angle % 360;
-	    this.obj3d.quaternion.setFromAxisAngle(vec1.set(0, 0, -1), MathUtils.degToRad(angle));
+	    this.obj3d.quaternion.setFromAxisAngle(vec1.set /* (0,1,0) */(0, 0, -1), MathUtils.degToRad(angle));
 	  }
 	  get yaw() {
 	    // 左右转角
@@ -76394,7 +76406,7 @@
 	      maxClipFactor: 1,
 	      text: model.name,
 	      sizeInfo: {
-	        width2d: 150
+	        width2d: 200
 	      },
 	      rectBorderThick: 1,
 	      borderColor: {
@@ -76409,11 +76421,11 @@
 	        b: 255,
 	        a: 1.0
 	      },
-	      textshadowColor: 'black',
+	      //textshadowColor:'black',
 	      backgroundColor: {
-	        r: 100,
-	        g: 100,
-	        b: 100,
+	        r: 0,
+	        g: 0,
+	        b: 0,
 	        a: 0.3
 	      },
 	      borderRadius: 6,
@@ -82498,84 +82510,6 @@
 	        model.dispatchEvent('rotation_changed');
 	      }
 	    });
-
-	    /* 
-	    for(let [model, keys] of this.pathKeys){//路径。开头结尾和别的衔接过渡
-	        
-	                keys.find(key=>{
-	            if(key.path.points.length < 2) return
-	            let startToFade = key.time - maxClipFadeTime/2
-	            let endFade = key.time + key.dur + maxClipFadeTime/2
-	            atPath = time >= key.time && time <= key.time + key.dur
-	            if(atPath){
-	                atPath = key //找到一个就退出 
-	                return true
-	            }  
-	            if(key.time + key.dur < time) lastPath = key
-	            else if(key.time > time && !nextPath) nextPath = key
-	             
-	        })
-	        pathStates.set(model,{atPath, lastPath, nextPath })
-	        
-	        
-	        if(atPath){//沿着curve行走,目视curve前方  (参照CameraAnimationCurve,搜quaFromCurveTan)
-	            let percent = THREE.Math.clamp((time - atPath.time) / atPath.dur, 0, 1)
-	            let {position , quaternion} = this.getPoseAtPathKey(atPath, percent, model)  //模型文件先保证其center在脚底,如果要我手动将bound底部对齐路径高度再说
-	            model.position.copy(position);
-	            model.quaternion.copy(quaternion)  
-	            model.dispatchEvent('position_changed') //暂时都这么写,以后再判断是否真的改变了
-	            model.dispatchEvent('rotation_changed') 
-	        } 
-	         
-	        
-	    }
-	    
-	    
-	    
-	    
-	    for(let [model, keys] of this.poseKeys){
-	              if(keys.length == 0) continue 
-	        let {atPath, lastPath, nextPath} = pathStates.get(model) || {}
-	          
-	        tweens.scale = new Tween(keys.map(e=>e.time), keys.map(e=>e.scale)) 
-	        model.scale.copy(tweens.scale.lerp(time))
-	        let pathToPoseKey = keys 
-	        if(!atPath ){
-	            keys = keys.slice()
-	            let addPathToPoseKey = (pathKey, percent)=>{ //把当前前后的path姿态加入帧
-	                let {position , quaternion} = this.getPoseAtPathKey(pathKey, percent, model)
-	                let fakeKey = {
-	                    isPath : true,
-	                    time: pathKey.time + pathKey.dur * percent,
-	                    pos:position , qua:quaternion
-	                } 
-	                let index = keys.findIndex(e=>e.time > pathKey.time) 
-	                if(index == -1){
-	                    index = keys.length
-	                } 
-	                keys = [...keys.slice(0,index), fakeKey, ...keys.slice(index,keys.length)]
-	            }
-	            lastPath && addPathToPoseKey(lastPath, 1)
-	            nextPath && addPathToPoseKey(nextPath, 0)
-	            
-	             
-	            tweens.pos = new Tween(keys.map(e=>e.time), keys.map(e=>e.pos))
-	            tweens.qua = new Tween(keys.map(e=>e.time), keys.map(e=>e.qua))
-	            
-	          
-	               let position = tweens.pos.lerp(time)
-	            let quaternion = tweens.qua.lerp(time)
-	            
-	            model.position.copy(position)
-	            model.quaternion.copy(quaternion)
-	        
-	            model.dispatchEvent('position_changed')
-	            model.dispatchEvent('rotation_changed') 
-	            
-	        } 
-	       
-	     
-	    }   */
 	    var _loop = function _loop(keys) {
 	      if (keys.length == 0) return 1; // continue
 	      var weights = keys.map((key, i) => {

Những thai đổi đã bị hủy bỏ vì nó quá lớn
+ 1 - 1
public/lib/potree/potree.js.map


+ 26 - 20
src/sdk/cover/index.js

@@ -659,7 +659,6 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
                 let model = viewer.images360.currentPano.pointcloud
                 if(!isFlyToTag || model.dataset_id == modelId){ //保存编辑热点时的视角,如果在全景模式,只有点位在所加模型上时才保存
                     pose.panoId = viewer.images360.currentPano.originID 
-                    //pose.model = model.result_  //无法被json化,好像没用到所以注释 
                     pose.posInModel = Potree.Utils.datasetPosTransform({ toDataset: true, position: camera.position.clone(), object:model })
                     pose.rotInModel = Potree.Utils.datasetRotTransform({ toDataset: true, quaternion: camera.quaternion.clone(), getQuaternion: true, pointcloud:model }).toArray() //拿第一个数据集
                 }
@@ -668,26 +667,31 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
                 target.copy(Potree.Utils.datasetPosTransform({ toDataset: true, position: target.clone(), datasetId: modelId,  }))
             }
             
-            //console.log('getPose',position, target)
+            if(isFlyToTag){
+                pose.maxDis = 15, pose.isFlyToTag = true,  pose.modelId = modelId //补一下
+            }
+            
+            console.log('getPose', pose)
             return pose
         },
         
         
         comeTo(o = {}) {
-            //console.log('comeTo',o.position, o.target)
+            console.log('comeTo',o )
             //飞到某个点  
             
             let deferred = $.Deferred()
             let fly = ()=>{
                 
                 if(o.panoId != void 0){
-                    let model = o.model.model
-                    let pano = model.panos.find(a=>a.originID == o.panoId)
+                    
+                    let pano = viewer.images360.panos.find(a=>a.originID == o.panoId)
+                    let model = pano.pointcloud 
                     if(pano){
                         o.rotInModel = new THREE.Quaternion().fromArray(o.rotInModel)
                         let quaternion = Potree.Utils.datasetRotTransform({ fromDataset: true, quaternion: o.rotInModel, getQuaternion: true, object:model})  
 
-                        o.model.flyInPano(pano, {quaternion, duration:0, callback(){
+                        model.result_.flyInPano(pano, {quaternion, duration: o.dur||0, callback(){
                             o.callback && o.callback()
                             deferred.resolve(true)
                         }})
@@ -699,22 +703,30 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
                 }/* else if(requestInPano){
                     requestInPano.result_.flyOutPano()
                 } */else{
+                    Potree.settings.displayMode = 'showPointCloud'  
                     if (o.modelId != void 0) {
                         ['position', 'target'].forEach(e => { 
                             if (o[e]) {
                                 o[e] = Potree.Utils.datasetPosTransform({ fromDataset: true, datasetId: o.modelId, position: o[e] })
                             }
                         })
-                    }
+                    } 
                 }
-            
+                viewer.scene.view.setView($.extend({}, o, {
+                    duration: o.dur,
+                    callback: () => {
+                        o.callback && o.callback()
+                        deferred.resolve(true)
+                    }
+                }))
+                return deferred.promise()
                 
             }
            
             if (o.distance || o.maxDis) {
                 //o.isFlyToTag = true
                 let requestShowPano
-                let position = o.target || o.position
+            let position = o.focusPos || o.target || o.position
                 if(o.isFlyToTag){
                     let r = sdk.canTurnToPanoMode(position, 5)//热点新需求:如果附近有漫游点就飞到全景模式
                     if(r){
@@ -722,6 +734,7 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
                     }else{
                         if(o.panoId != void 0 || o.modelId != void 0){ 
                             return fly()    //使用保存的视角
+                             
                         }
                         Potree.settings.displayMode = 'showPointCloud'  
                     }
@@ -736,18 +749,11 @@ export const enter = ({ dom, mapDom, isLocal, lonlat, scenes, laserRoot, laserOS
                 return rusult.promise
                
             }else{
-                fly()
+                return fly()
             }
             
 
-            viewer.scene.view.setView($.extend({}, o, {
-                duration: o.dur,
-                callback: () => {
-                    o.callback && o.callback()
-                    deferred.resolve(true)
-                }
-            }))
-            return deferred.promise()
+            
         },
         comeToByLatLng(lonlat){//飞到指定经纬度 
             let pos = viewer.transform.lonlatToLocal.forward(lonlat)
@@ -2564,7 +2570,7 @@ function load4dkkMedias(model){//加载四维看看的一些媒体物品
     let {sceneJsonPath,surveillancePath} = model.props.raw    
      
     if(sceneJsonPath){//box图片视频 
-        Potree.loadFile(sceneJsonPath,null,(json)=>{
+        Potree.loadFile(sceneJsonPath+ '?m='+Date.now(),null,(json)=>{
             console.log(model,  'sceneJson', json)
             //json.surveillances //监控开关? 'video'
             if(json.boxPhotos || json.boxVideos){
@@ -2594,7 +2600,7 @@ function load4dkkMedias(model){//加载四维看看的一些媒体物品
         
     }
     if(surveillancePath){//监控 
-        Potree.loadFile(surveillancePath,null,(json)=>{
+        Potree.loadFile(surveillancePath + '?m='+Date.now(),null,(json)=>{
             
             console.log(model,  'surveillance', json)
             json.forEach((e)=>{