mrdoob/three.js — pull request #5628 by m-schuetz (2014-11-14 14:05:08+00:00)
Title: fixed rendering indexed pointclouds

Fix for https://github.com/mrdoob/three.js/issues/4763

This code checks if indices are defined. If indices are defined but no offsets, all indices will be rendered

_gl.bindBuffer( _gl.ELEMENT_ARRAY_BUFFER, indices.buffer );
_gl.drawElements( _gl.POINTS, indices.length, type, 0);

If offsets are also defined, then then all indices between offset.start and offset.start + offset.count are rendered. Not sure what offset.index does.

In this case, indices were stored in an Uint16Array array. Is this always the case? Is there another way of finding the gl type (_gl.UNSIGNED_SHORT) other than checking the type of the array with instanceof?

Took the raycasting example and modified the indexed point cloud.
The indexed pointcloud has indices from 0 to 5000
The point cloud with indices and offsets has 2 offets. One from 0 to 5000 and another from 10000 to 15000.

Without fix: http://potree.org/stuff/threejs/fix_indexed_pointclouds/examples/indexed_pointcloud.html
With fix: http://potree.org/stuff/threejs/fix_indexed_pointclouds/examples/indexed_pointcloud_fixed.html

Note that in the example without the fix, raycasting omits the points that are not indexed but they are rendered anyway.