Skip to content

Latest commit

 

History

History

DynamicTerrain

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

readme.md

Dynamic Terrain

What's the DynamicTerrain

The DynamicTerrain is an extension for BabylonJS.
This object provides a way to display a terrain dynamically morphed from a map of 3D data.

dynamicTerrain

Installation

Just download the javascript file (dynamicTerrain.js or, recommended, the minified version dynamicTerrain.min.js) from the BabylonJS extension repository folder DynamicTerrain/dist : https://github.com/BabylonJS/Extensions/tree/master/DynamicTerrain/dist

Then in your code, declare this script in a html tag after the script tag declaring Babylon.js :

<script src="babylon.js"></script>
<script src="dynamicTerrain.min.js"></script>

How to use it ?

The dynamic terrain is a mesh that morphs on a logical data map.
This map is a simple flat array of successive 3D coordinates (x, y, z) as floats.
It can be as huge as you need, as long as you've enough memory. This won't be rendered anyway.
The map must be passed to the dynamic terrain constructor as well as the number of subdivisions on the map width and depth.

var mapCoords = [some_big_flat_array_of_coordinates];
var mapWidthPointNb = 2000;     // 2000 points in the map width
var mapDepthPointNb = 1000;    // 1000 points in the map depth
var terrainSub = 100;           // the terrain wil be 100x100 vertices only
var mapParams = {
    mapData: mapCoords,
    mapSubX: mapWidthPointNb,
    mapSubZ: mapDepthPointNb,
    terrainSub: terrainSub
};

var terrain = new BABYLON.DynamicTerrain("terrain", mapParams, scene);
var terrainMesh = terrain.mesh;
terrainMesh.diffuseTexture = myNiceTexture;

The whole documentation is accessible here : https://github.com/BabylonJS/Extensions/tree/master/DynamicTerrain/documentation/dynamicTerrainDocumentation.md

Some documented examples are here :
https://github.com/BabylonJS/Extensions/tree/master/DynamicTerrain/documentation/dynamicTerrainExamples.md