intermediate

Additional Shapes


Additional Shapes

Ground From a Height Map

Example :

var ground = BABYLON.MeshBuilder.CreateGroundFromHeightMap("gdhm", url, {width: 6, subdivsions: 4}, scene);

Don't forget the url parameter.

Properties, all optional :

property value default value
width (number) size of the map width 10
height (number) size of the map height 10
subdivisions (number) number of map subdivisions 1
minHeight (number) minimum altitude 0
maxHeigth (number) maximum altitude 1
onReady (function) a callback js function that is called and passed the just built mesh (mesh) => {return;}
updatable (boolean) true if the mesh is updatable false

Disc

Remember you can create any kind of regular plane polygon with CreateDisc() Example :

var disc = BABYLON.MeshBuilder.CreateDisc("disc", {tessellation: 3}, scene); // makes a triangle

Properties, all optional :

property value default value
radius (number) the radius of the disc or polygon 0.5
tessellation (number) the number of disc/polygon sides 64
arc (number) ratio of the circumference between 0 and 1 1
updatable (boolean) true if the mesh is updatable false
sideOrientation (number) side orientation DEFAULTSIDE

Torus

Example :

var torus = BABYLON.MeshBuilder.CreateTorus("torus", {thickness: 0.2}, scene);

Properties, all optional :

property value default value
diameter (number) diameter of the torus 1
thickness (number) thickness of its tube 0.5
tessellation (number) number of segments along the circle 16
updatable (boolean) true if the mesh is updatable false
sideOrientation (number) side orientation DEFAULTSIDE

Torus Knot

Example :

var torus = BABYLON.MeshBuilder.CreateTorusKnot("tk", {}, scene);

Properties, all optional :

property value default value
radius (number) radius of the torus knot 2
tube (number) thickness of its tube 0.5
radialSegments (number) number of radial segments 32
tubularSegments (number) number of tubular segments 32
p (number) number of windings 2
q (number) number of windings 3
updatable (boolean) true if the mesh is updatable false
sideOrientation (number) side orientation DEFAULTSIDE

A Playground Example of the above Shapes -


Tiled Ground

Example :

var tiledGround = BABYLON.MeshBuilder.CreateTiledGround("tgd", {subdivsions: {w:4, h:6} }, scene);

Properties, all optional :

property value default value
xmin (number) map min x coordinate value -1
zmin (number) map min z coordinate value -1
xmax (number) map max x coordinate value 1
zmin (number) map max z coordinate value 1
subdivisions ( {w: number, h: number} ) number of subdivisions (tiles) on the height and the width of the map {w: 6, h: 6}
precision ( {w: number, h: number} ) number of subdivisions on the height and the width of each tile {w: 2, h: 2}
updatable (boolean) true if the mesh is updatable false

Example of Tiled Ground -


.

Full explanation of creating a tiled ground by its original code writer here.

NOTE: this uses the legacy method of BABYLON.Mesh.CreateTiledGround;

Updatable

Where an additional shape has an updatable parameter in its options it means that it is possible to alter the data associated with each vertex of the mesh and so alter the shape of the mesh. For more information see Updating Vertices

Further Reading

Intermediate

Parametric Shapes Polyhedra Shapes

Advanced

Ribbons In Detail Maths Makes Ribbons Decals