removed outdated docs

This commit is contained in:
mschuetz 2014-05-24 00:42:24 +02:00
parent d47dcdff19
commit 03eda5fca0
5 changed files with 0 additions and 403 deletions

View File

@ -1,18 +0,0 @@
# How to use gulp.js to build the library
## Installation
npm install -g gulp
npm install --save-dev
## Usage
gulp clean // Deletes the build directory
gulp test // Runs Javascript test "jshint"
gulp docs // Build documentation
gulp debug // Builds script files, watches for changes
// and starts a simple webserver (port:3000)
gulp build // Builds script files
If Gulp.js is watching for changes, stop with `ctrl+c`.

View File

@ -1,85 +0,0 @@
# Documentation
* [File Format Description](./file_format.md)
* [Materials and Rendermodes](./materials_and_rendermodes.md)
* [How Does Loading Nodes Work?](./how_does_loading_nodes_work.md)
* [How to create or load your own pointclouds](how_to_create_or_load_your_own_pointclouds.md)
* [gulp builds (testing, building documentation and single minified script file, ...)](build.md)
## Introduction
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.
| ![](./images/r.png "") | ![](./images/r1.png "") | ![](./images/r_and_r1.png "") | ![](./images/r_and_rx.png "") |
| ------------- |:-------------:| -----:| --- |
| root | r0, first child of root | root and r0 combined | root and all its children combined |
## Getting Started
1. Deploy potree on a webserver.
2. Open lion.html.
This should be the result:
![](./images/lion_demo_screenshot.jpg)
And this is what happens inside lion.html:
Initialize potree inside the canvas element:
var canvas = document.getElementById("canvas");
var success = Potree.init(canvas);
if(!success){
return;
}
Load a point cloud and add it to the scene:
var scene = Potree.currentScene;
var cloudURL = "resources/pointclouds/lion_takanawa/cloud.js";
var pcoNode = POCLoader.load(cloudURL);
scene.rootNode.addChild(pcoNode);
Directly manipulate the transformation matrix of the point cloud node:
In this case, the point cloud was upside down so it has to be mirrored along the y-axis.
pcoNode.transform = [1, 0, 0, 0,
0, -1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1];
Transform the camera:
var cam = scene.activeCamera;
cam.rotateY(Math.PI/2);
cam.translate(-1,-1,-1);
Set the point Size:
var material = MaterialManager.getMaterial("pointCloud");
material.pointSize = 1;
A high LOD multiplicator will display more nodes that are small or far away:
Potree.Settings.LODMultiplicator = 20.0;
## Compatibility
| Browser | Result |
| -------------------- |:-------------:|
| Chrome 32 | works |
| Firefox 26 | works |
| Safari | works |
| Opera 19 | works |
| Internet Explorer 11 | does not work |
## License
Potree is available under the [FreeBSD License](http://en.wikipedia.org/wiki/BSD_licenses) license.

View File

@ -1,93 +0,0 @@
# How Does Loading Nodes Work?
Relevant classes are:
* <b>PointCloudOctree</b> <br>
Manages the octree. Contains methods that finds currently visible nodes for rendering
or loading.
* <b>PointCloudOctreeNode</b><br>
The hierarchy consists of instances of this class. Contains methods to load or unload
point cloud data.
* <b>PointCloudOctreeSceneNode</b><br>
A subclass of SceneNode that can be attached to the scenegraph.
Contains the PointCloudOctree instance.
* <b>POCLoader</b><br>
Loads the point cloud hierarchy from a file.
## Loading Data
At first, <b>POCLoader.load(file)</b> 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, <b>PointCloudOctree.prepareRender()</b> 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 <b>PointcloudOctree.processLoadQueue()</b>.
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]);
}
}
}
}
<b>PointcloudOctreeNode.loadCloudAjax(node)</b> creates an asynchronous XMLHttpRequest
to read the point cloud data from the corresponding file in _./data_.
Read more about loading point data through XMLHttpRequests in
[How To Create Your Own Pointcloud Loader](how_to_create_your_own_pointcloud_loader.md).
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.
<b>PointcloudOctreeNode.lruNodes</b> (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.
<b>PointcloudOctree.cleanupCache(bytesNeeded, exceptionsRenderQueue)</b>
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.

View File

@ -1,130 +0,0 @@
# How To Create Or Load Your Own Pointclouds
This section will explain some approaches to create and display your own point cloud data without using
the PointCloudOctree and some important things to consider regarding performance.
* Use [Typed Arrays](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays) for your point data.<br>
They're fast and since the last step is to send point data as a typed array to the GPU,
it's best to use them at all times.
* Allocate all the memory you need to store your points at the beginning. <br>
Avoid resizing arrays. Each point usually requires 16 bytes so initialize your ArrayBuffer with numPoints*16.
## Building A Buffer From Scratch
In this example, we'll create a procedurally generated patch. <br>
![](./images/procedural_patch.png "")
Each point needs 16 bytes. The first step is to create a buffer that can store all points,
as well as 2 views. floatView is required to write xyz coordinates in the buffer and byte view
is required to write rgba colors.
var width = 100;
var depth = 100;
var numPoints = width*depth;
var buffer = new ArrayBuffer(numPoints*16);
var floatView = new Float32Array(buffer);
var byteView = new Uint8Array(buffer);
In the next step, we'll write coordinates and colors into the buffer.
var offset = 0;
for(var i = 0; i < width; i++){
for(var j = 0; j < depth; j++){
var x = 10*((i / width)-0.5);
var z = 10*((j / depth)-0.5);
var y = Math.cos(x) * Math.sin(z);
var r = 100*(y+1);
var g = 0;
var b = 0;
floatView[4*offset+0] = x;
floatView[4*offset+1] = y;
floatView[4*offset+2] = z;
byteView[16*offset+12] = r;
byteView[16*offset+13] = g;
byteView[16*offset+14] = b;
byteView[16*offset+15] = 255;
offset++;
}
}
Now that the buffer is finished, you'll have to describe its contents with some PointAttributes:
var pointAttributes = new PointAttributes();
pointAttributes.add(PointAttribute.POSITION_CARTESIAN);
pointAttributes.add(PointAttribute.RGBA_PACKED);
And send the data to the GPU. This is done by creating a PointCloud object and
setting the vertex buffer data:
var pointCloud = new PointCloud("cloud", pointAttributes);
pointCloud.setVertexBufferData(buffer);
pointCloud.size = numPoints;
In the last step, we create a PointCloudSceneNode from our pointCloud data and attach it to the rootNode:
var sceneNode = new PointCloudSceneNode("procedural patch", scene.rootNode, pointCloud);
## Loading A Buffer With XMLHttpRequests
XMLHttpRequests can be used to fetch data from a page or file on a webserver.
It's usually used to load html or text files but it is also possible to load array buffers
that contain point cloud data.
First, create a request to an URL. We're about to request arraybuffer data so
we have to use an asynchronous request.
var url = ...
var async = true;
var xhr = new XMLHttpRequest();
xhr.open('GET', url, async);
These 2 settings specify that we want arraybuffer data:
xhr.responseType = 'arraybuffer';
xhr.overrideMimeType('text/plain; charset=x-user-defined');
Since we're using an asynchronous request, we must specify a function that is called when
our request state changes. Once the request is finished, xhr.readyState is set to 4 so we will check
for this case. We also have to check xhr.status. A value of 200 means, that the request was successfull.
If it was, we retrieve the buffer from xhr.response and do something with it inside displayPointCloud(buffer, url).
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
// when accessing local files, req.status will be 0
if (xhr.status == 200 || xhr.status == 0) {
var buffer = xhr.response;
displayPointCloud(buffer, url);
} else {
console.log('Failed to load file! HTTP status: ' + xhr.status + ", file: " + url);
}
}
};
Let's say, buffer is already in the correct format. We can send it directly to the GPU without
further processing and then attach it to the scene:
displayPointCloud = function(buffer, name) {
var pointAttributes = new PointAttributes();
pointAttributes.add(PointAttribute.POSITION_CARTESIAN);
pointAttributes.add(PointAttribute.RGBA_PACKED);
var pointCloud = new PointCloud(name, pointAttributes);
pointCloud.setVertexBufferData(buffer);
pointCloud.size = buffer.byteLength / pointAttributes.byteSize;
var sceneNode = new PointCloudSceneNode("pointcloud node", Potree.currentScene.rootNode, pointCloud);
};
## Unloading a PointCloud
Sometimes it's necessary to delete unused point clouds in order to free memory for new point clouds.
Use PointCloud.unload to delete data from the GPU.
var pointcloud = ...
pointcloud.unload()

View File

@ -1,77 +0,0 @@
# Materials And Rendermodes
The default material for point clouds is an instance of PointCloudMaterial with the name "pointCloud".
In order to change its attributes, you have to retrieve it by calling:
var material = MaterialManager.getMaterial("pointCloud");
There are 3 rendermodes available:
* <b>FIXED_CIRCLE</b>
Render points as circles with a fixed size. The pointSize attribute indicates the pixel diameter.
* <b>WEIGHTED_CIRCLE</b>
Render points as circles with a size depending on the distance to the viewer.
* <b>FILTERED_SPLAT</b>
Interpolates between overlapping points. High quality but very slow.
You can change the render mode by calling
material.renderMode = PointCloudRenderMode.FIXED_CIRCLE;
| ![](./images/lion_fixed_circles.jpg "") | ![](./images/lion_weighted_circles.jpg "") | ![](./images/lion_filtered_splats.jpg "") |
| --------------------------------------- | ------------------------------------------ | ----------------------------------------- |
| FIXED_CIRCLES with point-size 2. All points have pixel diameter 2.| WEIGHTED_CIRCLES with point-size 1. Size varies depending on distance from camera. | FILTERED_SPLATS with point-size 1. In this mode, points have the same size as with WEIGHTED_CIRCLES, but overlapping points are interpolated. |
## PointCloudMaterial
PointCloudMaterial is actually a combination of other materials.
It dispatches render calls to the material in use.
## FixedPointSizeMaterial
Used when rendermode is set to FIXED_CIRCLE.
The _render(sceneNode, renderer)_ function extracts extracts all pointCloud from sceneNode,
that should be rendered. The _renderPointClouds()_ function invokes the WebGL
draw calls.
## WeightedPointSizeMaterial
Used when rendermode is set to WEIGHTED_CIRCLE.
It works the same way as FixedPointSizeMaterial, except with a different vertex shader
that adjusts the point size according to the distance from the viewer.
## FilteredSplatsMaterial
Used when rendermode is set to FILTERED_SPLATS.
This material is based on the paper [High Quality Splatting on Today's GPUs](http://graphics.ucsd.edu/~matthias/Papers/HighQualitySplattingOnGPUs.pdf).
The idea is, that overlapping points should be blended together, if their distance to the viewer is roughly the same.
Simple point rendering usualy leads to overlapping points:<br>
![](./images/filtered_splats_overlapping.png "")
This material consists of 3 passes:
1. <b>Depth-Pass</b> Renders the point cloud into a depth buffer. Depth values are pushed away from the viewer with an offset given by uBlendDepth.
Fragments within this offset-range will be blended together. Fragments that are farther away will be discarded during the depth test.
2. <b>Attribute-Pass</b> Renders the point cloud with weighted attributes and blend mode set to ADD.
The weight function gives fragments that are closer to the center a higher weight.<br>
The result of this pass is a weighted sum of overlapping attributes, stored in the RGB component:<br>
![](./images/filtered_splats_weighted_sum.png "")
And the sum of weights, stored in the alpha component:<br>
![](./images/filtered_spats_sum_of_weights.png "")
3. <b>Normalization-Pass</b> In this pass, the output of the previous pass is normalized by
dividing the weighted sum of colors in the RGB component by the sum of weights in the alpha component.
It's essentially a screen-space filter so this time, not the point cloud is rendered but
a rectangle that spans the whole screen with the output of the previous pass
as the its texture. This is one possible result:<br>
![](./images/filtered_splats_normalized.png "")<br>
The smoothness of the transition depends on the weight function. By adjusting the weight function, you can get
very smooth or relatively sharp borders.