Point Cloud Decoder Module (pointcloud.ts)
Module path: web_rviz/src/ros/pointcloud.ts
Purpose
Converts sensor_msgs/PointCloud2 payloads into Three.js-ready position/color buffers.
Public API
ParsedPointCloud
frameId: source frame id.positions:Float32Arraywith lengthcount * 3.colors:Float32Arraywith lengthcount * 3.count: valid decoded point count.
decodePointCloud2(rawMessage: unknown, maxPoints: number): ParsedPointCloud | null
Behavior:
Supports both base64 and
number[]binary payloads.Requires
x/y/zfields; returnsnullwhen missing.Uses
rgb/rgbaif present and meaningfully varied.Otherwise falls back to RViz-style depth coloring based on the decoded
zrange, with distance-based coloring as the last fallback when the depth range collapses.Samples points according to
maxPointsfor stable rendering performance.Skips invalid numeric values.