diff --git a/README.md b/README.md index 57632a8c..214fd1a9 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Reference: [Potree: Rendering Large Point Clouds in Web Browsers](https://www.cg ### Build and Run -Make sure you have [node.js](http://nodejs.org/) installed +Install [node.js](http://nodejs.org/) Install all dependencies, as specified in package.json: @@ -26,14 +26,14 @@ Install all dependencies, as specified in package.json: npm install ``` -Use the `npm run build` command to +Use `npm run build` to create ./build/potree. + +Use the `npm start` command to * create ./build/potree * watch for changes to the source code and automatically create a new build on change * start a web server at localhost:1234. -Use `npm start` to start a development server with automatic reloading whenever code changes. - Go to http://localhost:1234/examples/ to test the examples. ### Convert diff --git a/examples/github.html b/examples/github.html index 9f5d4d4c..efbe3cd6 100644 --- a/examples/github.html +++ b/examples/github.html @@ -2,8 +2,8 @@ - + - +
- - + + @@ -28,7 +28,7 @@
Virtual RealityOriented ImagesGeopackageClassificationsCamera AnimationLoad ProjectBasic ViewerOriented ImagesGeopackageClassificationsCamera AnimationLoad Project
@@ -39,8 +39,8 @@ - - + + @@ -57,7 +57,7 @@
ToolbarMatcapBasic ViewerHeidentorLionLion LASToolbarMatcapVirtual RealityHeidentorLionLion LAS
diff --git a/examples/page.json b/examples/page.json index 5ad1a5ee..08208423 100644 --- a/examples/page.json +++ b/examples/page.json @@ -1,6 +1,6 @@ { "examples": [ - {"thumb": "thumbnails/vr.jpg", "label": "Virtual Reality", "url": "vr.html"}, + {"thumb": "thumbnails/viewer.png", "label": "Basic Viewer", "url": "viewer.html"}, {"thumb": "thumbnails/oriented_images.jpg", "label": "Oriented Images", "url": "oriented_images.html"}, {"thumb": "thumbnails/geopackage.jpg", "label": "Geopackage", "url": "geopackage.html"}, {"thumb": "thumbnails/classifications.jpg", "label": "Classifications", "url": "classifications.html"}, @@ -9,7 +9,7 @@ {"thumb": "thumbnails/toolbar.jpg", "label": "Toolbar", "url": "toolbar.html"}, {"thumb": "thumbnails/matcap.jpg", "label": "Matcap", "url": "matcap.html"}, - {"thumb": "thumbnails/viewer.png", "label": "Basic Viewer", "url": "viewer.html"}, + {"thumb": "thumbnails/vr.jpg", "label": "Virtual Reality", "url": "vr.html"}, {"thumb": "thumbnails/heidentor.png", "label": "Heidentor", "url": "heidentor.html"}, {"thumb": "thumbnails/lion.png", "label": "Lion", "url": "lion.html"}, {"thumb": "thumbnails/lion_las.png", "label": "Lion LAS", "url": "lion_las.html"}, diff --git a/src/PotreeRenderer.js b/src/PotreeRenderer.js index 1daeeb11..d2758a82 100644 --- a/src/PotreeRenderer.js +++ b/src/PotreeRenderer.js @@ -696,7 +696,6 @@ export class Renderer { } } - let world = node.sceneNode.matrixWorld; worldView.multiplyMatrices(view, world); @@ -714,13 +713,18 @@ export class Renderer { shader.setUniform("uDebug", false); } - let isLeaf = false; - if(node instanceof PointCloudOctreeNode){ - isLeaf = Object.keys(node.children).length === 0; - }else if(node instanceof PointCloudArena4DNode){ - isLeaf = node.geometryNode.isLeaf; - } - shader.setUniform("uIsLeafNode", isLeaf); + // let isLeaf = false; + // if(node instanceof PointCloudOctreeNode){ + // isLeaf = Object.keys(node.children).length === 0; + // }else if(node instanceof PointCloudArena4DNode){ + // isLeaf = node.geometryNode.isLeaf; + // } + // shader.setUniform("uIsLeafNode", isLeaf); + + // let isLeaf = node.children.filter(n => n != null).length === 0; + // if(!isLeaf){ + // continue; + // } // TODO consider passing matrices in an array to avoid uniformMatrix4fv overhead diff --git a/src/modules/Loader_1.8/OctreeLoader_1_8.js b/src/modules/Loader_1.8/OctreeLoader_1_8.js index f0b38ba3..d781c0e5 100644 --- a/src/modules/Loader_1.8/OctreeLoader_1_8.js +++ b/src/modules/Loader_1.8/OctreeLoader_1_8.js @@ -17,59 +17,63 @@ export class NodeLoader{ let byteOffset = node.byteOffset; let byteSize = node.byteSize; - let response = await fetch(this.url, { - headers: { - 'content-type': 'multipart/byteranges', - 'Range': `bytes=${byteOffset}-${byteOffset + byteSize}`, - }, - }); + try{ + let response = await fetch(this.url, { + headers: { + 'content-type': 'multipart/byteranges', + 'Range': `bytes=${byteOffset}-${byteOffset + byteSize}`, + }, + }); - let workerPath = Potree.scriptPath + '/workers/OctreeDecoderWorker.js'; - let worker = Potree.workerPool.getWorker(workerPath); + let workerPath = Potree.scriptPath + '/workers/OctreeDecoderWorker.js'; + let worker = Potree.workerPool.getWorker(workerPath); - worker.onmessage = function (e) { + worker.onmessage = function (e) { - let data = e.data; - let buffers = data.attributeBuffers; + let data = e.data; + let buffers = data.attributeBuffers; - Potree.workerPool.returnWorker(workerPath, worker); + Potree.workerPool.returnWorker(workerPath, worker); - let geometry = new THREE.BufferGeometry(); - - for(let property in buffers){ + let geometry = new THREE.BufferGeometry(); + + for(let property in buffers){ - let buffer = buffers[property].buffer; + let buffer = buffers[property].buffer; + + if(property === "POSITION_CARTESIAN"){ + geometry.addAttribute('position', new THREE.BufferAttribute(new Float32Array(buffer), 3)); + }else if(property === "RGBA"){ + geometry.addAttribute('rgba', new THREE.BufferAttribute(new Uint8Array(buffer), 4, true)); + } - if(property === "POSITION_CARTESIAN"){ - geometry.addAttribute('position', new THREE.BufferAttribute(new Float32Array(buffer), 3)); - }else if(property === "RGBA"){ - geometry.addAttribute('rgba', new THREE.BufferAttribute(new Uint8Array(buffer), 4, true)); } + // indices ?? - } - // indices ?? + node.geometry = geometry; + node.loaded = true; + node.loading = false; + Potree.numNodesLoading--; + }; - node.geometry = geometry; - node.loaded = true; - node.loading = false; - Potree.numNodesLoading--; - }; + let buffer = await response.arrayBuffer(); - let buffer = await response.arrayBuffer(); + let pointAttributes = node.octreeGeometry.pointAttributes; + let scale = node.octreeGeometry.scale; - let pointAttributes = node.octreeGeometry.pointAttributes; - let scale = node.octreeGeometry.scale; - - let message = { - buffer: buffer, - pointAttributes: pointAttributes, - scale: scale, - min: node.boundingBox.min, - }; - - worker.postMessage(message, [message.buffer]); + let message = { + buffer: buffer, + pointAttributes: pointAttributes, + scale: scale, + min: node.boundingBox.min, + }; + worker.postMessage(message, [message.buffer]); + }catch(e){ + console.log(`failed to load ${node.name}`); + console.log(`trying again!`); + } } }