Potree.PointCloudOctreeGeometry = function(){ Potree.PointCloudOctree.lru = Potree.PointCloudOctree.lru || new LRU(); this.numNodesLoading = 0; } Potree.PointCloudOctreeGeometryNode = function(name, pcoGeometry, boundingBox){ this.name = name; this.index = parseInt(name.charAt(name.length-1)); this.pcoGeometry = pcoGeometry; this.boundingBox = boundingBox; this.children = {}; this.numPoints = 0; this.level = null; } Potree.PointCloudOctreeGeometryNode.prototype.addChild = function(child){ this.children[child.index] = child; child.parent = this; } Potree.PointCloudOctreeGeometryNode.prototype.load = function(){ if(this.loading === true || this.pcoGeometry.numNodesLoading > 3){ return; } if(Potree.PointCloudOctree.lru.numPoints + this.numPoints >= Potree.pointLoadLimit){ Potree.PointCloudOctree.disposeLeastRecentlyUsed(this.numPoints); } this.pcoGeometry.numNodesLoading++; this.loading = true; var url = this.pcoGeometry.octreeDir + "/" + this.name; var node = this; var xhr = new XMLHttpRequest(); xhr.open('GET', url, true); xhr.responseType = 'arraybuffer'; xhr.overrideMimeType('text/plain; charset=x-user-defined'); xhr.onreadystatechange = function() { if (xhr.readyState === 4) { if (xhr.status === 200 || xhr.status === 0) { var buffer = xhr.response; node.bufferLoaded(buffer); } else { console.log('Failed to load file! HTTP status: ' + xhr.status + ", file: " + url); } } }; try{ xhr.send(null); }catch(e){ console.log("fehler beim laden der punktwolke: " + e); } } Potree.PointCloudOctreeGeometryNode.prototype.bufferLoaded = function(buffer){ //console.log("loaded: " + this.name); var geometry = new THREE.BufferGeometry(); var numPoints = buffer.byteLength / 16; var positions = new Float32Array(numPoints*3); var colors = new Float32Array(numPoints*3); var color = new THREE.Color(); var fView = new Float32Array(buffer); var uiView = new Uint8Array(buffer); for(var i = 0; i < numPoints; i++){ positions[3*i] = fView[4*i]; positions[3*i+1] = fView[4*i+1]; positions[3*i+2] = fView[4*i+2]; color.setRGB(uiView[16*i+12], uiView[16*i+13], uiView[16*i+14]); colors[3*i] = color.r /255; colors[3*i+1] = color.g / 255; colors[3*i+2] = color.b / 255; } geometry.addAttribute('position', new THREE.Float32Attribute(positions, 3)); geometry.addAttribute('color', new THREE.Float32Attribute(colors, 3)); geometry.boundingBox = this.boundingBox; this.geometry = geometry; this.loaded = true; this.loading = false; this.pcoGeometry.numNodesLoading--; } Potree.PointCloudOctreeGeometryNode.prototype.dispose = function(){ delete this.geometry; this.loaded = false; //console.log("dispose: " + this.name); }