How to update the “Height map picture url” from a Mesh.CreateGroundFromHeightMap in babylonjs

Hello everyone,
I’m new to babylon and try to make a gallery with differents maps using the function “CreateGroundFromHeightMap”

My question is :
is there a way to update the parameter " *Height Map url" in the function .CreateGroundFromHeightMap ?

if its not possible , what is the best solution to remove it and create a new one ?

For the moment , i tried this code :

var ground = BABYLON.Mesh.CreateGroundFromHeightMap(“ground”, “textures/heightMapHNomPNG8TRANS.png”,2700, 1688, 700,-00, 100, scene, false);
ground.material = groundMaterial4;

and to remove it, i used this :
ground.dispose();

it work fine one time but if i create a new one like this, i cant remove it anymore with dispose();

Another idea could be using .setEnabled() but i don’t know if it a good solution.

Thanks for your help,
Pierre (sorry for my bad english)

This should work. Can you repro in the Playground? There must be something wrong :wink:

hey ,
thanks for your reply .
yes it work but only ones
i made a playground that similar to what i want even its not exactly like that.
https://www.babylonjs-playground.com/#1AFXQI#36
so my button works one time but than dispose() is not working anymore. Maybe it s a basic things of javascript i miss :slight_smile:
thanks
Pierre

This is because the ground variable is not global:
https://www.babylonjs-playground.com/#1AFXQI#37

1 Like

Hi thanks a lot i was always trying to declare the variable inside the function create scene .
Thanks