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);