Can you update the point size of a point cloud without re-creating the point cloud?

Can you update the point size of a point cloud without re-creating the point cloud?

At the moment I am copying and remaking the point cloud to change the point size. This is a slow process. Is it possible to do a faster update of an existing point cloud?

const pcs = new BABYLON.PointsCloudSystem(
Settings.ui.pointcloud.babylonScenePrefix,
Settings.ui.pointcloud.pointSize,
scene);

or the opacity

pcs.buildMeshAsync().then((mesh) => {
mesh.rotationQuaternion = value.pcs.mesh.rotationQuaternion;
mesh.position = value.pcs.mesh.position;
mesh.hasVertexAlpha = true;
mesh.visibility = Settings.ui.pointcloud.pointOpacity;

// Copies the point cloud
  public copyPointCloud(value: any) {
    const scene = this.getScene();
    const pcs = new BABYLON.PointsCloudSystem(
      Settings.ui.pointcloud.babylonScenePrefix,
      **Settings.ui.pointcloud.pointSize,**
      scene);
    let idx = 0;
    const numParts = value.pcs.nbParticles;

    pcs.addPoints(numParts, particle => {
      this.copyPointFunction(particle, idx, value.pcs);
      idx++;
    });
    pcs.buildMeshAsync().then((mesh) => {
      mesh.rotationQuaternion = value.pcs.mesh.rotationQuaternion;
      mesh.position = value.pcs.mesh.position;
      mesh.hasVertexAlpha = true;
      **mesh.visibility = Settings.ui.pointcloud.pointOpacity;**

      // Delete old pcs, Save current pcs info
      value.pcs.dispose();
      value.pcs = pcs;

      // Update frame and point counters.
      this.updateFrameAndPointCounters();

      // Update the point cloud
      this.updateColourisation(Settings.ui.pointcloud.colourisation.method, true);
    });
  }


 private copyPointFunction(particle: BABYLON.Particle,
                            idx: number,
                            pcs: BABYLON.PointsCloudSystem ) {

    particle.position = new BABYLON.Vector3(
      pcs.particles[idx].position.x,
      pcs.particles[idx].position.y,
      pcs.particles[idx].position.z,
      );
    particle.color = pcs.particles[idx].color;
  }

I think this should work:

pcs.mesh.material.pointSize = XXX;
1 Like

Oh nice! Thanks - I couldn’t spot the function to change it - I was looking in the pcs.
I think that runs about 10x-100X faster than recreating the point cloud.

1 Like

For point clouds, we need to use this way. For other kind of meshes, it can be useful to change the scaling proeprty.

1 Like