Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow a color for a PointCloud2 #196

Merged
merged 1 commit into from
Oct 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion build/ros3d.js
Original file line number Diff line number Diff line change
Expand Up @@ -3788,11 +3788,13 @@ function decode64(x) {
* * rootObject (optional) - the root object to add this marker to
* * size (optional) - size to draw each point (default 0.05)
* * max_pts (optional) - number of points to draw (default 100)
* * color (optional) - point color (otherwise taken from the topic)
*/
ROS3D.PointCloud2 = function(options) {
options = options || {};
this.ros = options.ros;
this.topicName = options.topic || '/points';
this.color = options.color;

this.particles = new ROS3D.Particles(options);
this.rosTopic = undefined;
Expand Down Expand Up @@ -3830,10 +3832,14 @@ ROS3D.PointCloud2.prototype.processMessage = function(message){
buffer = Uint8Array.from(decode64(message.data)).buffer;
}
var dv = new DataView(buffer);
var color;
if(this.color !== undefined){
color = new THREE.Color(this.color);
}
for(var i=0;i<n;i++){
var pt = read_point(message, i, dv);
this.particles.points[i] = new THREE.Vector3( pt['x'], pt['y'], pt['z'] );
this.particles.colors[ i ] = new THREE.Color( pt['rgb'] );
this.particles.colors[ i ] = color || new THREE.Color( pt['rgb'] );
this.particles.alpha[i] = 1.0;
}

Expand Down
Loading