Creating Set Shapes

Common 3D Shapes

These common shapes cover 2D shapes such as horizontal planes (ground), vertical planes and regular polygons along with 3D shapes such as cuboids, spheres, ellipsoids and toruses.

To create these meshes you use

const mesh = BABYLON.MeshBuilder.Create<MeshType>(name, options, scene);

where the options object properties vary according to the type of mesh. Using an empty object, , the meshes will default to given sizes, usually unit ones. The scene parameter is optional and defaults to the current scene.

Two useful properties are updatable and instance. When a parametric mesh is created with its options property updatable set to true then you can change the values within the shape defining properties and re-render the mesh with these new values by using the instance property as the following line drawing example indicates.

//creates lines using the vector3 myPoints array
const myLines = BABYLON.MeshBuilder.CreateLines("lines", {points: myPoints});
// update some or all values in myPoints array
myPoints[1] = new BABYLON.Vector3(1, 2, 3);
// updates the existing instance of myLines by pointing the instance property to it
myLines = BABYLON.MeshBuilder.CreateLines("lines", {points: myArray, instance: myLines});

Whilst you can change values within a property you cannot the number of elements of the property. All the parametric meshes, except for the Lathe, CreatePolygon and ExtendPolygon can have their shape updated in this way.

It is still possible to use the form

const mesh = BABYLON.Mesh.Create<MeshType>(name, required_param1, required_param2, ..., scene, optional_parameter1, ........);

The scene parameter is compulsory when used with optional parameters. You will still find this method in playgrounds.

Coming next

Creating A Box
Learn how to create a box in Babylon.js.
Creating A Box
Creating A Tiled Box
Learn how to create a tiled box in Babylon.js.
Creating A Tiled Box
Creating A Sphere
Learn how to create a sphere in Babylon.js.
Creating A Sphere
Creating A Cylinder
Learn how to create a cylinder in Babylon.js.
Creating A Cylinder
Creating A Capsule
Learn how to create a capsule in Babylon.js.
Creating A Capsule
Creating A Plane
Learn how to create a plane in Babylon.js.
Creating A Plane
Creating A Tiled Plane
Learn how to create a tiled plane in Babylon.js.
Creating A Tiled Plane
Creating A Disc
Learn how to create a disc in Babylon.js.
Creating A Disc
Creating A Torus
Learn how to create a torus in Babylon.js.
Creating A Torus
Creating A Torus Knot
Learn how to create a torus knot in Babylon.js.
Creating A Torus Knot
Creating A Ground
Learn how to create a ground in Babylon.js.
Creating A Ground
Creating Ground From a Height Map
Learn how to create ground from a height map in Babylon.js.
Creating Ground From a Height Map
More On Height Maps
Learn more about height maps in Babylon.js.
More On Height Maps
Creating A Tiled Ground
Learn how to create a tiled ground in Babylon.js.
Creating A Tiled Ground
Creating A 3D Text object
Learn how to create a 3d text in Babylon.js.
Creating A 3D Text object