xzw 3 年之前
父节点
当前提交
f4a0bf989a
共有 3 个文件被更改,包括 88 次插入61 次删除
  1. 67 35
      public/lib/potree/potree.js
  2. 1 1
      public/lib/potree/potree.js.map
  3. 20 25
      src/sdk/cover/index.js

+ 67 - 35
public/lib/potree/potree.js

@@ -74350,9 +74350,10 @@ void main() {
 
             this.targets = [];  
     		this.createPath();
-            this.duration = 5;
+            this.duration = 5; 
     		this.percent = 0;
             this.currentIndex = 0;
+            this.durations = [];
             this.quaternions = [];
             
             if(!Potree.settings.isTest){
@@ -74460,6 +74461,7 @@ void main() {
             }else {
                 position.copy(posInfo.position);
                 target.copy(posInfo.target);
+                 
             }
                 
             this.posCurve.addPoint(position, index/* , true */);
@@ -74467,6 +74469,9 @@ void main() {
             let targetSvg = new HandleSvg(target, colors.target);
             targetSvg.visible = this.visible; 
             this.targets = [...this.targets.slice(0,index), targetSvg, ...this.targets.slice(index,length)];
+            if(this.useDurSlice){//不使用全局的duration,而是分段的
+                this.durations = [...this.durations.slice(0,index), posInfo.duration, ...this.durations.slice(index,length)];
+            }
             
             
     		this.dispatchEvent({
@@ -74523,7 +74528,9 @@ void main() {
     			index
     		});
             this.targetLines.remove(this.targetLines.children[index]);
-            
+            if(this.useDurSlice){
+                this.durations.splice(index, 1);
+            }
             
         }
 
@@ -74594,41 +74601,64 @@ void main() {
             if(length<2){
                 return this.newPointsPercents = []
             }
-            const maxSpaceDur = this.duration / length;  //每两点之间修改间隔时间后,最大时间
-            const durPerRad = 0.8;     //每弧度应该占用的时间
-            const minSpaceDur =  Math.min(0.8, maxSpaceDur);//每两点之间修改间隔时间后,最小时间
-            const maxAngleSpaceDur = MathUtils.clamp(durPerRad * Math.PI, minSpaceDur, maxSpaceDur );// 最大可能差距是180度
-            
-            
-            
-            var percents = this.posCurve.pointsPercent; 
             var newPercents = [0];
             
             
-            for(let i=1;i<length;i++){
-                let diff = (percents[i] - percents[i-1]) * this.duration;  //间隔时间
-                let percent; 
-                let curMin = minSpaceDur;
-                if(diff < maxAngleSpaceDur){ //若小于最大旋转时间
-                    let rad = this.quaternions[i].angleTo(this.quaternions[i-1]); 
-                    curMin = MathUtils.clamp(rad * durPerRad, minSpaceDur, maxSpaceDur);
-     
-                }  
-
-                diff = Math.max(diff, curMin); 
-                percent = newPercents[i-1] + (diff / this.duration); //得到新的percent
+            
+            if(this.useDurSlice){ //已经设定好了每一段的duration的话
+                let sums = [0];
+                let sum = 0, last = this.durations[0];
+                for(let i=1;i<length;i++){
+                    let duration = this.durations[i];
+                    sum += duration;   
+                    last = duration;
+                    sums.push(sum); 
+                }
+                for(let i=1;i<length;i++){ 
+                    newPercents.push(sum == 0 ? i/length : sums[i] / sum);
+                } 
+                 
+            }else {
                 
+                const maxSpaceDur = this.duration / length;  //每两点之间修改间隔时间后,最大时间
+                const durPerRad = 0.8;     //每弧度应该占用的时间
+                const minSpaceDur =  Math.min(0.8, maxSpaceDur);//每两点之间修改间隔时间后,最小时间
+                const maxAngleSpaceDur = MathUtils.clamp(durPerRad * Math.PI, minSpaceDur, maxSpaceDur );// 最大可能差距是180度
                 
-                newPercents.push(percent); 
-            }
-            
-            let maxPercent = newPercents[length-1];  //最后一个,若扩充过时间,就会>1
+                
+                
+                var percents = this.posCurve.pointsPercent; 
+                
+                
+                
+                for(let i=1;i<length;i++){
+                    let diff = (percents[i] - percents[i-1]) * this.duration;  //间隔时间
+                    let percent; 
+                    let curMin = minSpaceDur;
+                    if(diff < maxAngleSpaceDur){ //若小于最大旋转时间
+                        let rad = this.quaternions[i].angleTo(this.quaternions[i-1]); 
+                        curMin = MathUtils.clamp(rad * durPerRad, minSpaceDur, maxSpaceDur);
+         
+                    }  
 
+                    diff = Math.max(diff, curMin); 
+                    percent = newPercents[i-1] + (diff / this.duration); //得到新的percent
+                    
+                    
+                    newPercents.push(percent); 
+                }
+                
+                let maxPercent = newPercents[length-1];  //最后一个,若扩充过时间,就会>1
 
-            if( !math.closeTo(maxPercent, 1)){
-                let scale = 1 / maxPercent; //需要压缩的比例 <1  这一步会让实际得到的间隔更小 
-                newPercents = newPercents.map(e=> e*=scale ); 
+
+                if( !math.closeTo(maxPercent, 1)){
+                    let scale = 1 / maxPercent; //需要压缩的比例 <1  这一步会让实际得到的间隔更小 
+                    newPercents = newPercents.map(e=> e*=scale ); 
+                }
+                    
+                
             }
+            
             this.newPointsPercents = newPercents;
             //console.log(newPercents)
         }
@@ -74890,7 +74920,7 @@ void main() {
             this.posCurve.dispose();
             //this.targetCurve.dispatchEvent({type:'dispose'}) 
             this.targets.forEach(e=>e.dispose());
-            
+            this.durations = [];
             this.node.parent.remove(this.node);
         }
     }
@@ -115063,12 +115093,12 @@ ENDSEC
                 }else {
                     viewer.outlinePass.edgeStrength = 100;
                 }
-                console.log('selectModel', model);
+                //console.log('selectModel', model)
                 
             }else { 
                 viewer.outlinePass.selectedObjects = [];
                 this.selected = null;
-                console.log('selectModel', null);
+                //console.log('selectModel', null)
             } 
             
             
@@ -118656,9 +118686,10 @@ ENDSEC
                     /* const position = Potree.Utils.datasetPosTransform({ fromDataset: true, position: cpdata.position, datasetId: Potree.settings.originDatasetId })
                     const target = Potree.Utils.datasetPosTransform({ fromDataset: true, position: cpdata.target, datasetId: Potree.settings.originDatasetId })
                      */
-                    const position = new THREE.Vector3().copy(cpdata.position);
-                    const target = new THREE.Vector3().copy(cpdata.target);  
-                    const cp = animation.createControlPoint(null,{position, target}); 
+                    const position = new Vector3().copy(cpdata.position);
+                    const target = new Vector3().copy(cpdata.target);  
+                    const duration = cpdata.duration;
+                    const cp = animation.createControlPoint(null, {position, target, duration}); 
                 }
             }
             
@@ -123097,6 +123128,7 @@ ENDSEC
                     this.modules.PanoEditor = PanoEditor$1;
                 }else if(Potree.settings.editType == "merge"){
                     this.modules.MergeEditor = MergeEditor; 
+                    this.modules.CamAniEditor = CamAniEditor;
                 }
                 
             }else {

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


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

@@ -102,10 +102,12 @@ export const enter = (dom) => {
         getPose() {//获取当前点位和朝向
             const camera = viewer.scene.getActiveCamera()
             const target = viewer.scene.view.getPivot()
-            const position = viewer.scene.view.position
+            const position = viewer.scene.view.position 
+            console.log('getPose',position, target)
             return { position, target }
         },
         comeTo(o = {}) {
+            console.log('comeTo',o.position, o.target)
             //飞到某个点  
             if(o.modelId){ 
                 ['position','target'].forEach(e=>{
@@ -250,9 +252,9 @@ export const enter = (dom) => {
         */
      
         
-        enterSceneGuide(pathArr){//导览
-            
-            console.log(data)
+        enterSceneGuide(pathArr){//导览  (不需要修改参数)
+            let editor = viewer.modules.CamAniEditor
+            console.log('pathArr',pathArr)
         
             /* type SceneGuidec = {
               position: {x,y,z}
@@ -261,35 +263,28 @@ export const enter = (dom) => {
               speed: number
             }
             sceneGuide = enterSceneGuide(sceneGuidePaths)
-
-            type SceneGuide = {
-
-              bus: Emitter<{ changePoint: number; playComplete: void }>
-              addPoint: (index: number, path: SceneGuidePath) => void
-              deletePoint: (index: number) => void
-              play: () => void
-              pause: () => void
-              clear: () => void
-            }
-            } */
-            
-            
-            let editor = viewer.modules.CamAniEditor
-            /* let posTran = function (position, target) {
+  
+              let posTran = function (position, target) {
                 position = Potree.Utils.datasetPosTransform({ fromDataset: true, position: position, datasetId: Potree.settings.originDatasetId })
                 target = Potree.Utils.datasetPosTransform({ fromDataset: true, position: target, datasetId: Potree.settings.originDatasetId })
                 return { position, target }
-            } */
+            } 
             if (data) {
                 data.points.forEach(e => {
                     //let { position, target } = posTran(e.position, e.target)
                     e.position = position
                     e.target = target
                 })
+            }*/
+            let data = {
+                duration: pathArr.reduce(function(total, currentValue ){return total+currentValue.time}, 0),
+                points: pathArr
             }
             let animation = editor.createAnimation(data)
             //注:最多只存在一条导览
-
+            animation.useDurSlice = true 
+             
+            
             let bus = mitt()
 
             //播放完成
@@ -303,7 +298,7 @@ export const enter = (dom) => {
 
             return {
                 bus,
-                addPoint(index, position_, target_) {
+                /* addPoint(index, position_, target_) {
                     let { position, target } = posTran(position_, target_)
                     animation.createControlPoint(index, { position, target })
                     animation.changeCallback()
@@ -311,7 +306,7 @@ export const enter = (dom) => {
                 deletePoint(index) {
                     animation.removeControlPoint(index)
                     animation.changeCallback()
-                },
+                }, */
                 play() {
                     /* var modeOld = Potree.settings.displayMode;
                     Potree.settings.displayMode = 'showPointCloud' */
@@ -320,9 +315,9 @@ export const enter = (dom) => {
                 pause() {
                     animation.pause()
                 },
-                setDuration(dur) {
+                /*setDuration(dur) {
                     animation.setDuration(dur)
-                },
+                }, */
                 clear() {
                     //删除
                     editor.removeAnimation(animation)