Can we use a heightmap mesh surfece to add Point cloud system points?

Hi team,

I’m tring to use a heightmap created from a Heatmap to creat a point cloud system effect, to display the heatmap on the heightmap surface.
But I always get this, a run time error: Uncaught TypeError: meshPos is null…

:exclamation: :person_raising_hand: IMPORTANT! PLEASE REPRODUCE YOUR ISSUE ON THE Playground FIRST! :person_raising_hand: :exclamation:

:thinking: Before asking a question

  • :mag_right: Search about your issue on the documentation. Maybe the problem you have is just a matter of understanding how the API works?
  • :mag_right: Search about your issue on the forum. Maybe someone else already had the same problem?

:question: How to ask a good question

  • :thought_balloon: Write a title that summarizes the specific problem: A good title will help others identify what are you talking about quickly.

    • Bad example: Shadow problem
    • Good example: Imported meshes on my scene don’t cast shadows
    • Bad example: Issue with GUI
    • Good example: GUI Button isn’t displayed on VR Session
  • :building_construction: Reproduce your issue on the Playground: This is the MOST IMPORTANT STEP! If we can see what you have tried on the Playground, and what the result of this is, we are much more likely to get what’s going on! And even if your problem is not happening on the Playground, but only on your environment, this already can give us clues what’s going on.

  • :person_in_lotus_position: Be patient: The team and forum users are all on different time zones, so your question might take a few hours to be seen. We try to answer everything as fast as we can, but remember we’re not robots :robot:

:package: Resources

Hello and welcome!

Are you able to reproduce your issue in the Playground - https://playground.babylonjs.com/ ?
Or at least to describe it so it would be possible to understand it better.

Sorry this is my first time.
I tried to use a box like the examples on the Playground, it’s works fine.
By the way, the heightmap and heatmap work fine before I turned to the point cloud system, in dynamicTexture and projectionTexture test applications.

Hi labris, thank you for your quick response and suggestions.

Hi,
I tried a ground by BABYLON.MeshBuilder.CreateGround(), it works on both
pcs.addSurfacePoints(ground, 10000) and pcs.addVolunePoints(ground, 10000).
Guess there’s a bug somewhere.

Hi labris,
It’s turn out to be a timing problem, the point system is initialized before the mesh loaded.
With the help of an AI asistant I modifed the code as following and the problem solved. Thanks anyway.

scene.executeWhenReady(() => {
let pcs= new BABYLON.PointsCloudSystem(“pcs”, 3, scene);
pcs.addSurfacePoints(ground2, 100000, BABYLON.PointColor.Color);
pcs.buildMeshAsync().then((mesh) => {
mesh.scaling = new BABYLON.Vector3(1, 1, 1);
mesh.material.pointSize = 0.1;
console.log(“Point cloud vertices count:”, mesh.getTotalVertices());
setTimeout(() => ground2.dispose(), 1000);
});
});

Pro tip: you can share your PGs with us by URL like so