Hello everyone
I have an height map and I want to hide it with check box to increase the performance. how can I dispose the height map when I turn off the check box and then rebuild it when I turn on the check box. how can I dispose the height map and rebuild it?
here is my PG: https://playground.babylonjs.com/#X2ULQN#69
here is my code, but I have some errors:
const tm = new TileManager(scene);
...
checkbox1.onIsCheckedChangedObservable.add(function (value) {
if (map) {
tm.update(true);
} else {
console.log("there is no map")
}
});
...
and then
class TileManager {
....
update(value) {
...
var ground;
if (value) {
ground = BABYLON.Mesh.CreateGroundFromHeightMap("ground", heightURL, width * factor, width * factor, 2, 0, 64, scene, true);
ground.position = new BABYLON.Vector3(
(tileX * factor - xTileBase + factor / 2) * width,
-factor * 0.1,
-(tileY * factor - yTileBase + factor / 2) * width
);
ground.material = material;
} else {
ground.dispose();
ground = BABYLON.Mesh.CreateGroundFromHeightMap("ground", "heightURL", 0, scene, true);
}
}