DynamicTerrain keeping constantly increasing dynamically

As said, DynamicTerrain keeping constantly increasing dynamically. Btw, it seems work in PlayGround but not in my project.
Any expert could help with how to make it just a fixed size thing at a position? Thanks a lot.

Source are copyied from somewhere as below.
var mapSubX = 1000; // point number on X axis
var mapSubZ = 800; // point number on Z axis

var mapData = new Float32Array(mapSubX * mapSubZ * 3); // 3 float values per point : x, y and z
var mapColors = new Float32Array(mapSubX * mapSubZ * 3); // x3 because 3 values per point : r, g, b
for (var l = 0; l < mapSubZ; l++) {
  for (var w = 0; w < mapSubX; w++) {
    mapData[3 * (l * mapSubX + w)] = (w - mapSubX * 0.5) * 2.0;
    mapData[3 * (l * mapSubX + w) + 1] = w / (l +1) * Math.sin(l / 2) * Math.cos(w / 2) * 2.0;
    mapData[3 * (l * mapSubX + w) + 2] = (l - mapSubZ * 0.5) * 2.0;

    mapColors[3 * (l * mapSubX + w)] = (0.5 + Math.random() * 0.2);
    mapColors[3 * (l * mapSubX + w) + 1] = (0.5 + Math.random() * 0.4);
    mapColors[3 * (l * mapSubX + w) + 2] = (0.5);
  }
}

var terrainSub = 500;             // 20 terrain subdivisions
var params = {
  mapData: mapData,               // data map declaration : what data to use ?
  mapSubX: mapSubX,               // how are these data stored by rows and columns
  mapSubZ: mapSubZ,
  mapColors: mapColors,
  terrainSub: terrainSub          // how many terrain subdivisions wanted
}

var terrain = new DynamicTerrain("t", params, scene);
var terrainMaterial = new StandardMaterial("tm", scene);
terrain.useCustomVertexFunction = true;
terrain.updateVertex = function(vertex: { position: { y: number; }; color: { r: number; b: number; }; }, i: any, j: any) {
  if (vertex.position.y > 2.0) {
    vertex.color.r = 1.0;
    vertex.color.b = 0.2;
  }
};

terrain.update(true);

That’s hard to say without a repro. Even an external link would help, if the repro in the Playground does work.

Are you using a clipping plane for this mesh/material?

Thank you @Evgeni_Popov for the response. I used clipping plane but not for this mesh.

Btw, I didn’t use original DynamicTerrain extension, but a ES6 Compatible Dynamic Terrain Babylon Extension.
It’s really cool and I see no similar things happened by someone else.

You should make sure that the code from this version is in sync with the original dynamic terrain extension code. Maybe there has been some updates/fixes since then?

@Evgeni_Popov Thanks for the comments that I am trying to check any updates/fixes so far. I also work out a minimal repro in the attachment though my poor javascript skill.

3DDynamicTerrain.zip (1.6 MB)

Btw, Would you please do my a favor about how could I make a way out. Please just check out “3DDynamicTerrain\src\hooks\useBabylon\core.ts”.

The extent of the visible terrain is governed by the terrainSub parameter: you should increase it if you want the visible terrain to go farther.

Yes, I try to increase terrainSub and got a larger terrain so that the limit could extend to the edge of skybox.
I think maybe I’m not expressing my needs precisely. Actually I just need something called “StaticTerrain”. Finally I comments all lines like this.update(true); to make it statically. May it’s just a workaround.

Leave that for now.