xzw пре 2 година
родитељ
комит
9e37d8889a

+ 21 - 21
src/PointCloudOctreeGeometry.js

@@ -141,7 +141,7 @@ export class PointCloudOctreeGeometryNode extends PointCloudTreeNode{
 		this.pcoGeometry.loader.load(this);
 	}
 
-	loadHierachyThenPoints(){
+	loadHierachyThenPoints(){//旧的 新的见shim
 		let node = this;
 
 		// load hierarchy
@@ -220,28 +220,28 @@ export class PointCloudOctreeGeometryNode extends PointCloudTreeNode{
 		if ((node.level % node.pcoGeometry.hierarchyStepSize) === 0) {
 			// let hurl = node.pcoGeometry.octreeDir + "/../hierarchy/" + node.name + ".hrc";
 			let hurl = node.pcoGeometry.octreeDir + '/' + node.getHierarchyPath() + '/' + node.name + '.hrc';
-            let startLoad = ()=>{
-                let xhr = XHRFactory.createXMLHttpRequest();
-                xhr.open('GET', hurl, true);
-                xhr.responseType = 'arraybuffer';
-                xhr.overrideMimeType('text/plain; charset=x-user-defined');
-                xhr.onreadystatechange = () => {
-                    if (xhr.readyState === 4) {
-                        if (xhr.status === 200 || xhr.status === 0) {
-                            let hbuffer = xhr.response;
-                            callback(node, hbuffer);
-                        } else {
-                            console.log('Failed to load file! HTTP status: ' + xhr.status + ', file: ' + hurl);
-                            Potree.numNodesLoading--;
-                        }
+             
+            let xhr = XHRFactory.createXMLHttpRequest();
+            xhr.open('GET', hurl, true);
+            xhr.responseType = 'arraybuffer';
+            xhr.overrideMimeType('text/plain; charset=x-user-defined');
+            xhr.onreadystatechange = () => {
+                if (xhr.readyState === 4) {
+                    if (xhr.status === 200 || xhr.status === 0) {
+                        let hbuffer = xhr.response;
+                        callback(node, hbuffer);
+                    } else {
+                        console.log('Failed to load file! HTTP status: ' + xhr.status + ', file: ' + hurl);
+                        Potree.numNodesLoading--;
                     }
-                };
-                try {
-                    xhr.send(null);
-                } catch (e) {
-                    console.log('fehler beim laden der punktwolke: ' + e);
-                } 
+                }
+            };
+            try {
+                xhr.send(null);
+            } catch (e) {
+                console.log('fehler beim laden der punktwolke: ' + e);
             } 
+            
 		}
 	}
 

+ 4 - 18
src/custom/modules/panos/Panorama.js

@@ -195,7 +195,7 @@ class Panorama extends THREE.EventDispatcher{
         let src =  `${Potree.settings.urls.prefix1}/images/${this.originID}.jpg`  //`server\test\SS-t-P1d6CwREny2\${this.id}.jpg`    //`${Potree.settings.urls.prefix1}/${Potree.settings.webSite}/${this.pointcloud.sceneCode}/data/${this.pointcloud.sceneCode}/depthmap/${this.originID}.png`
         //console.log('开始下载depthImg', this.id)
         
-        let startLoad = ()=>{
+        let startLoad = (src)=>{
             let texture = texLoader.load( src, ()=>{
                 this.skyboxTex = texture
                 this.dispatchEvent({type:'loadedTex',   loaded:true})
@@ -214,14 +214,7 @@ class Panorama extends THREE.EventDispatcher{
             
         }
         
-        if(Potree.getFileUrl){//更换url
-            Potree.getFileUrl(src).then(realUrl => {
-                src = realUrl
-                startLoad()
-            })  
-        }else{ 
-            startLoad()
-        }
+        Potree.getRealUrl(src, startLoad)
         
 	}
     
@@ -236,7 +229,7 @@ class Panorama extends THREE.EventDispatcher{
         
         //console.log('开始下载depthImg', this.id)
         
-        let startLoad = ()=>{
+        let startLoad = (src)=>{
             
             let texture = texLoader.load( src, ()=>{
                 this.depthTex = texture
@@ -256,14 +249,7 @@ class Panorama extends THREE.EventDispatcher{
             texture.generateMipmaps = false
         }
         
-        if(Potree.getFileUrl){//更换url
-            Potree.getFileUrl(src).then(realUrl => {
-                src = realUrl
-                startLoad()
-            })  
-        }else{ 
-            startLoad()
-        }
+        Potree.getRealUrl(src, startLoad)
         
 	}
  

+ 29 - 32
src/custom/potree.shim.js

@@ -880,10 +880,10 @@ BinaryLoader.prototype.load = function(node, callback){//解析点云
     if (this.version.equalOrHigher('1.4')) {
         url += '.bin';
     }
-    url += '?m='+node.pcoGeometry.timeStamp //add
+    //url += '?m='+node.pcoGeometry.timeStamp //add
     
     
-    let startLoad = ()=>{
+    let startLoad = (url)=>{
         let xhr = XHRFactory.createXMLHttpRequest();
         xhr.open('GET', url, true);
         xhr.responseType = 'arraybuffer';
@@ -907,16 +907,8 @@ BinaryLoader.prototype.load = function(node, callback){//解析点云
         }
     }  
     
-    if(Potree.getFileUrl){//更换url
-        Potree.getFileUrl(hurl).then(realUrl => {
-            hurl = realUrl
-            startLoad()
-        })  
-    }else{ 
-        startLoad()
-    }
-
-    
+     
+    Potree.getRealUrl(url, startLoad)
     
 }
 
@@ -1867,28 +1859,33 @@ PointCloudOctreeGeometryNode.prototype.loadHierachyThenPoints = function(pointcl
     if ((node.level % node.pcoGeometry.hierarchyStepSize) === 0) {
         // let hurl = node.pcoGeometry.octreeDir + "/../hierarchy/" + node.name + ".hrc";
         let hurl = node.pcoGeometry.octreeDir + '/' + node.getHierarchyPath() + '/' + node.name + '.hrc';
-        hurl += '?m='+node.pcoGeometry.timeStamp //add
-        
-        let xhr = XHRFactory.createXMLHttpRequest();
-        xhr.open('GET', hurl, true);
-        xhr.responseType = 'arraybuffer';
-        xhr.overrideMimeType('text/plain; charset=x-user-defined');
-        xhr.onreadystatechange = () => {
-            if (xhr.readyState === 4) {
-                if (xhr.status === 200 || xhr.status === 0) {
-                    let hbuffer = xhr.response;
-                    callback(node, hbuffer);
-                } else {
-                    console.log('Failed to load file! HTTP status: ' + xhr.status + ', file: ' + hurl);
-                    Potree.numNodesLoading--;
+        //hurl += '?m='+node.pcoGeometry.timeStamp //add
+        let startLoad = (hurl)=>{
+            let xhr = XHRFactory.createXMLHttpRequest();
+            xhr.open('GET', hurl, true);
+            xhr.responseType = 'arraybuffer';
+            xhr.overrideMimeType('text/plain; charset=x-user-defined');
+            xhr.onreadystatechange = () => {
+                if (xhr.readyState === 4) {
+                    if (xhr.status === 200 || xhr.status === 0) {
+                        let hbuffer = xhr.response;
+                        callback(node, hbuffer);
+                    } else {
+                        console.log('Failed to load file! HTTP status: ' + xhr.status + ', file: ' + hurl);
+                        Potree.numNodesLoading--;
+                    }
                 }
-            }
-        };
-        try {
-            xhr.send(null);
-        } catch (e) {
-            console.log('fehler beim laden der punktwolke: ' + e);
+            };
+            try {
+                xhr.send(null);
+            } catch (e) {
+                console.log('fehler beim laden der punktwolke: ' + e);
+            }  
         } 
+            
+        Potree.getRealUrl(hurl, startLoad)
+        
+        
     }
 } 
 PointCloudOctreeGeometryNode.prototype.loadPoints = function(){

+ 10 - 1
src/custom/utils/math.js

@@ -621,7 +621,16 @@ var math = {
     linearClamp(value,  x1,x2, y1, y2){//x为bound.min, bound.max
         value = THREE.Math.clamp(value, x1,x2)
         return y1 + ( y2 - y1) * (value - x1)  / (x2 - x1)  
-    }
+    },
+    
+    
+    getStandardYaw(yaw1, yaw2) {
+        //使yaw1过渡到yaw2时朝角度差小的那边走。如果差距大于半个圆,就要反个方向转(把大的那个数字减去360度)
+        if (Math.abs(yaw1 - yaw2) > Math.PI) {
+            yaw1 > yaw2 ? (yaw1 -= Math.PI * 2) : (yaw2 -= Math.PI * 2)
+        }
+        return [yaw1, yaw2]
+    },
 };
 
  

+ 5 - 12
src/loader/POCLoaderNew.js

@@ -134,10 +134,10 @@ export class POCLoader {
             pco.timeStamp = timeStamp
             
              
-            let startLoad = ()=>{
-                pco.url = url;
+            let startLoad = (realUrl)=>{
+                pco.realUrl = realUrl;
                 let xhr = XHRFactory.createXMLHttpRequest();
-                xhr.open('GET', url /* +'?m='+timeStamp */, true);  
+                xhr.open('GET', realUrl /* +'?m='+timeStamp */, true);  
 
                 xhr.onreadystatechange = function () {
                     if (xhr.readyState === 4 && (xhr.status === 200 || xhr.status === 0)) {
@@ -251,15 +251,8 @@ export class POCLoader {
                 
             }
             
-            if(Potree.getFileUrl){//更换url
-                Potree.getFileUrl(url).then(realUrl => {
-                    url = realUrl
-                    startLoad()
-                })  
-            }else{
-                
-                startLoad()
-            }
+            Potree.getRealUrl(url, startLoad)
+
            
 		} catch (e) {
 			console.log("loading failed: '" + url + "'");