Hi,
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");
scene.getNodeByName(nodeName).dispose();
}
const pointCloud = new PointsCloudSystem(
nodeName,
resolution,
scene,
{ 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(
data.points[i].x,
-0.3,
data.points[i].y
);
particle.color = Color4.FromColor3(color, 1);
};
pointCloud.addPoints(data.points.length, addParticleProperties);
pointCloud.buildMeshAsync();