diff --git a/docs/file_format.md b/docs/file_format.md index 295bf5f7..eb67092d 100644 --- a/docs/file_format.md +++ b/docs/file_format.md @@ -1,5 +1,7 @@ # File Format +Version 1.6 + The potree file format partitions points into an octree. All octree nodes, intermediate as well as leaves, contain a sparse subsample of points. @@ -32,9 +34,16 @@ Each node may have up to 8 child nodes. The numbers from 0 to 7 inside the node indicate which child it is. Files inside the data directory are grouped into a hierarchical directory structure. -Each directory contains nodes for up to _hierarchyStepSize_ levels of the octree. +Each directory contains nodes for up to _X_ levels of the octree +and a hrc file that contains _(X + 1)_ levels of hierarchy for a given node, +where _X_ is the _hierarchyStepSize_. Subsequent nodes are stored in sub directories. +This image shows the contents of data/r for a step size of 5. It contains nodes for octree levels 0 to 4 and r.hrc which contains the hierarchy for octree levels 0 to 5. +Contents for level 5 to 9 and 10 to 12 are stored in subsequent directories. + +![](./images/directoy_hierarchy.png) + ## Hierarchy Chunks The hierarchy of a node is stored in .hrc files, in packets of 5 bytes. This list of 5-byte packets is a breadth-first traversal of the tree, starting in itself. * 1 byte with a mask of this node's children. E.g: 00000011 in the file r.hrc refers to the nodes r0 and r1 @@ -58,7 +67,7 @@ The file ./data/r.hrc will contain 2 packs of 5-bytes with the following data: The depth of the hierarchy in a .hrc file depends on the hierarchyStepSize which is set to 5 as of now. This means that at every 5th level there are .hrc files -that contain the next 5 levels of hierarchy. +that contain 6 levels of hierarchy (the node itself and the next 5 levels of descendants). ## Octree Hierarchy diff --git a/docs/images/directoy_hierarchy.png b/docs/images/directoy_hierarchy.png new file mode 100644 index 00000000..56f41e80 Binary files /dev/null and b/docs/images/directoy_hierarchy.png differ diff --git a/src/loader/POCLoader.js b/src/loader/POCLoader.js index 38b87763..baf6be90 100644 --- a/src/loader/POCLoader.js +++ b/src/loader/POCLoader.js @@ -28,6 +28,8 @@ POCLoader.load = function load(url, callback) { if(xhr.readyState === 4 && (xhr.status === 200 || xhr.status === 0)){ var fMno = JSON.parse(xhr.responseText); + var version = new Potree.Version(fMno.version); + // assume octreeDir is absolute if it starts with http if(fMno.octreeDir.indexOf("http") === 0){ pco.octreeDir = fMno.octreeDir; @@ -44,7 +46,7 @@ POCLoader.load = function load(url, callback) { var max = new THREE.Vector3(fMno.boundingBox.ux, fMno.boundingBox.uy, fMno.boundingBox.uz); var boundingBox = new THREE.Box3(min, max); var tightBoundingBox = boundingBox.clone(); - + if(fMno.tightBoundingBox){ tightBoundingBox.min.copy(new THREE.Vector3(fMno.tightBoundingBox.lx, fMno.tightBoundingBox.ly, fMno.tightBoundingBox.lz)); tightBoundingBox.max.copy(new THREE.Vector3(fMno.tightBoundingBox.ux, fMno.tightBoundingBox.uy, fMno.tightBoundingBox.uz)); @@ -81,7 +83,7 @@ POCLoader.load = function load(url, callback) { var root = new Potree.PointCloudOctreeGeometryNode(name, pco, boundingBox); root.level = 0; root.hasChildren = true; - if(pco.loader.version.upTo("1.5")){ + if(version.upTo("1.5")){ root.numPoints = fMno.hierarchy[0][1]; } root.numPoints = 0; @@ -91,7 +93,7 @@ POCLoader.load = function load(url, callback) { } // load remaining hierarchy - if(pco.loader.version.upTo("1.4")){ + if(version.upTo("1.4")){ for( var i = 1; i < fMno.hierarchy.length; i++){ var name = fMno.hierarchy[i][0]; var numPoints = fMno.hierarchy[i][1];