From 756ee423a56b0a5e779534bd731df0ce060f39f8 Mon Sep 17 00:00:00 2001 From: mschuetz Date: Fri, 14 Feb 2014 11:48:04 +0100 Subject: [PATCH] updated documentation --- doc/doc.md | 2 +- doc/how_does_loading_nodes_work.md | 89 +++++++++++++++++++++++++++++- 2 files changed, 89 insertions(+), 2 deletions(-) diff --git a/doc/doc.md b/doc/doc.md index 151679e2..826cca7f 100644 --- a/doc/doc.md +++ b/doc/doc.md @@ -8,7 +8,7 @@ Potree is a WebGL based viewer for large point clouds. The idea is that, similar to Google Maps, only visible parts up to a certain level of detail will be loaded and displayed. In order to achieve this, points are partitioned into an octree. The root node r contains a sparse subset of the data. All of its children contain another sparse subset which, combined, will gradualy increase -the level of detail. +the level of detail. | ![](./images/r.png "") | ![](./images/r1.png "") | ![](./images/r_and_r1.png "") | ![](./images/r_and_rx.png "") | | ------------- |:-------------:| -----:| --- | diff --git a/doc/how_does_loading_nodes_work.md b/doc/how_does_loading_nodes_work.md index bcf17c1e..f655a978 100644 --- a/doc/how_does_loading_nodes_work.md +++ b/doc/how_does_loading_nodes_work.md @@ -1,4 +1,91 @@ # How Does Loading Nodes Work? -TODO \ No newline at end of file +Relevant classes are: + +* PointCloudOctree
+Manages the octree. Contains methods that finds currently visible nodes for rendering +or loading. +* PointCloudOctreeNode
+The hierarchy consists of instances of this class. Contains methods to load or unload +point cloud data. +* PointCloudOctreeSceneNode
+A subclass of SceneNode that can be attached to the scenegraph. +Contains the PointCloudOctree instance. +* POCLoader
+Loads the point cloud hierarchy from a file. + +## Loading Data + +At first, POCLoader.load(file) reads the point cloud hierarchy from cloud.js and +builds a graph of _PointcloudOctreeNode_ instances. +This graph will be attached to a _PointCloudOctree_ instance. +During rendering, PointCloudOctree.prepareRender() traverses through nodes that +are visible from the current point of view. If it encounters a node whose point cloud data +has not been loaded, it will stop traversing further down the hierarchy and schedule +it for loading by adding it to _loadQueue_. + + // schedule loading of missing point cloud data + if (shouldBeRendered && current.pointCloud == null) { + if(!current.isLoading){ + this.loadQueue.push(current); + } + continue; + } + +The last step of _prepareRender() is a call to PointcloudOctree.processLoadQueue(). +Nodes in _loadQueue_ are sorted by their size and we want to load larger nodes first so +_processLoadQueue()_ will tell the first few nodes in _loadQueue_ to start loading +point cloud data by calling _PointcloudOctreeNode.loadCloudAjax(node)_. +The remaining nodes in the queue will be ignored. +They'll be loaded at a later time once all their ancestors have been loaded. +Additionaly, there are checks to make sure that the size of all loaded nodes does not +exceed the point cloud memory limit and that no more than _loadingNodesLimit_ +nodes are loaded at a time. + + // process the first x nodes in the queue. + if(this.loadQueue.length > 0 ){ + for(var i = 0; i < Math.min(x, this.loadQueue.length); i++){ + if(lru.byteSize + this.loadQueue[i].sizeInBytes() < PointcloudOctreeNode.memoryThreshold){ + if(this.nodesBeeingLoaded.length < this.loadingNodesLimit){ + PointcloudOctreeNode.loadCloudAjax(this.loadQueue[i]); + } + } + } + } + +PointcloudOctreeNode.loadCloudAjax(node) creates an asynchronous XMLHttpRequest +to read the point cloud data from the corresponding file in _./data_. +Once the request is finished, _PointcloudOctreeNode.loadCloudData(node, buffer, url)_ +is called to send the data directly to the GPU. + +## Cleanup Data + +Pointcloud data can be very large and often it might be necessary to unload some data +to create space for new data. +_PointcloudOctreeNode.memoryThreshold_ defines a limit for how much point cloud data +potree will load. If loading a new node exceeds this limit, potree will first remove +some old nodes that weren't rendered in a while. +PointcloudOctreeNode.lruNodes (least-recently-used nodes) contains a list of all loaded nodes, ordered by +the last time they've been rendered. Recently rendered nodes are at the end of the list. +PointcloudOctree.cleanupCache(bytesNeeded, exceptionsRenderQueue) +checks if the byte size of all currently loaded nodes, plus the additional size of +_bytesNeeded_ exceeds the limit. If it does, it will remove the first few nodes +of _lruNodes_, except nodes contained in _exceptionsRenderQueue_. +This is done to avoid removing nodes that were scheduled to be rendered. + + + + + + + + + + + + + + + +