potree icon indicating copy to clipboard operation
potree copied to clipboard

Wrong itemSize of rgba data in profile viewer

Open wanderingnature opened this issue 2 years ago • 2 comments

Related to the issue mentioned in: https://github.com/potree/potree/issues/1396

In profile.js the profile view is populated by the functions addPoints(data) and createBatch(data). Java console shows WebGL errors related to rgba having six elements when only 4 are allowed (and only 4 should be there). This error occurs from ProfileRenderer.js where gl.vertexAttribPointer(attributeLocation, bufferAttribute.itemSize, type, normalized, 0, 0); may be called in different situations. Error: [.WebGL-0x108038a6300] GL_INVALID_VALUE: Vertex attribute size must be 1, 2, 3, or 4. [.WebGL-0x108038a6300] GL_INVALID_OPERATION: An enabled vertex array has no buffer. This error was introduced when the LAS 1.4 and COPC functionality was added/merged.

The error only occurs when PotreeRenderer is rendering points in profile view, not in the full window (all points). This suggests that the error is not directly related to the COPC/LAZ1.4 functionality but perhaps the profile data object creation was not adapted to use changed data structures (I note changes in PointCloudEptGeometry.js for instance)

When the profile view opens the function addPoints(data){} is called. In the data object rgba has the problematic 6 elements. I am unable to figure out where the data object passed to addPoints() is created so I don't know where the actual root cause is...

You can avoid (work-around) the error by simply slicing 'rgba' out of data before proceeding with processing in profile.js delete data.data['rgba'];

Once rgba is deleted the profile window displays normally. But this brings up another problem. The performance of the profile view is very bad. When the view is called I see CPU spikes in Google Chrome Helper (renderer) and Google Chrome Helper (gpu) and the browser may hang for several minutes. I had reverted back to 1.8 so check the COPC/LAZ14 issue and find even there the profile viewer has very bad performance. You do not notice the performance issue in 1.8.2 because the rgba error causes no rendering to occur.

The COPC/LAZ1.4 functionality is really great - it would be so much better to just host copc.laz files rather than all the files that make up an EPT bundle. But without the profile view working and being performant it limits the use of 1.8.2 overall.

wanderingnature avatar Feb 23 '24 15:02 wanderingnature

Try to change next line in ProfileRequest.js: let numElements = attribute.array.length / numPoints; to: let numElements = attribute.itemSize;

I use only COPC files so it works for me, but if you support non-COPC files you should probably add something like: let numElements = geometery.root.copc ? attribute.itemSize : attribute.array.length / numPoints; I mean you can find somewhere if the octree is COPC or not. And of course this is workaround, it might be fixable in other place, but I didn't find out

askmyselfwhy avatar Feb 27 '24 18:02 askmyselfwhy

Thanks - I can generate COPC as well, but still the issue with performance remains it seems to me. I also tried the let numElements = attribute.itemSize; and it works too, but it is just a workaround as I had proposed. I currently use a customized 1.6 viewer but would like to move up to 1.8 - for the COPC mainly. But I need the height profile to perform.

wanderingnature avatar Mar 05 '24 03:03 wanderingnature