Creating Parametric Meshes

Parametric Shapes

These meshes are so called because their shape is defined by a an array of vector3 parameters and can be irregular in nature. You can produce a series of broken or unbroken lines across 3D space. In 2D you can produce an horizontal irregular convex or concave polygon, which may be extruded vertically into 3D. It is also possible to extrude the 2D outline along a path that travels in 3D space and vary its rotation and scale as it travels the path. You can also 'lathe' an outline to give a shape with rotational symmetry.

To create these meshes you use one of

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

where the options object properties vary according to the type of mesh. The scene parameter is optional and defaults to the current scene. One or more of the options properties will be used to set the vector3 data to define paths and outlines and you must set these.

All the parametric shapes, except for the CreateLathe, CreatePolygon and ExtrudePolygon have an instance property in the options. This is used to update the shape after creation provided its updatable options property was set to true. You can only change values in the shape defining data arrays not the size of the arrays.

Where possible playgrounds will give two examples; the first creating a mesh and the second updating it with the instance option. Comment out the latter to see the original mesh.

It is still possible to use the *Mesh" method to create these shapes. This has the forms

const mesh = BABYLON.Mesh.Create<MeshType>(name, required_param1, required_param2, ..., scene, optional_parameter1, ........);
const mesh = BABYLON.Mesh.Extrude<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 Lines
Learn how to create lines in Babylon.js.
Creating Dashed Lines
Learn how to create dashed lines in Babylon.js.
Creating A Line System
Learn how to create line systems in Babylon.js.
Creating Ribbons
Learn how to create ribbons in Babylon.js.
Ribbon In Detail
Dive into the details of ribbons in Babylon.js.
Ribbons With Math
Learn how to create ribbons with math in Babylon.js.
Creating Tubes
Learn how to create tubes in Babylon.js.
Extruding Shapes
Learn how to extrude shapes in Babylon.js.
Custom Extrusion
Learn how custom extrusion works in Babylon.js.
Learn how to use the lathe operation in Babylon.js.
Irregular Polygons
Learn about creating irregular polygons in Babylon.js.
Irregular Polygon Extrusion
Learn how extrude irregular polygons in Babylon.js.
Polygon Mesh Builder
Learn how to create polygons with Mesh Builder in Babylon.js.