Is this the right way to show frequently incoming point cloud data?


I have the feeling that I am bit wreckless with my resources here and I am wondering if this is correct.
I get some point cloud data in, let’s say 1000 data points with x,y,z position at 10 Hz per second.
These points are not at the same position with every message and there can be multiple sensors from which I receive data. Therefore I use the sensors data ID to distinguish them.

So on every point cloud I receive, I check if a PointsCloudSystem for this sensor already exists and delete it in this case. And then I create a new PointsCloudSystem and at it to the scene.

And I have the feeling, that this is not the most efficient way. I am also not sure if a PointsCloudSystem is the correct data type, although the name would suggest it.

My solution is working but CPU seems to be at 100% but not sure if it’s from the PointsCloudSystem.

      const nodeName = "sensorData" + data.Id.toString();

      // Check if some data is already shown and remove it
      const node = scene.getNodeByName(nodeName);
      if (node) {
        console.log("Removing point cloud");

      const pointCloud = new PointsCloudSystem(
        { updatable: false }
      const addParticleProperties = function(particle, i, s) {
        // particle is the current particle, the i-th one in the PCS and the s-th one in its group
        particle.position = new Vector3(
        particle.color = Color4.FromColor3(color, 1);

      pointCloud.addPoints(data.points.length, addParticleProperties);

You almost never want to recreate objects when you dont have to. Try just updating the positions. Not exactly clear on your data, but maybe if some sensors go active/inactive from frame to frame and thats why you’re recreating, id make a list of all sensors and just hide them not remove them.

Well that’s my problem. The amount of data points that are incoming is varying.

One sensor itself publishes data at 10hz, and each message has a different amount of data points in it. Could be just 10 or 1000.

It will be faster to set the new position data with PCS.mesh.setVerticesData("position", yourdata) than to recreate the whole PCS.


If you have a varying number of data points, you could create a system with the max number of points (let’s say, 1000), and if you receive a number of points below it, you set the “extra points” to a position hidden to the camera (like [-999,-999,-999]).

1 Like