Builds a box centered on the origin with width along X, height along Y and depth along
Z.
The three sizes, the side orientation and the shadow flag
The box mesh
Builds a cube centered on the origin with every edge size long.
The edge length, the side orientation and the shadow flag
The cube mesh
Builds a flat square of side size centered on the origin in the XY plane, facing the Z
axis; a single-sided plane is invisible from behind unless sideOrientation is double-sided.
The side length, the side orientation and the shadow flag
The plane mesh
Builds a sphere of the given diameter centered on the origin; segments sets how finely it
is divided, more being rounder and heavier.
The diameter, the segment count, the side orientation and the shadow flag
The sphere mesh
Builds a sphere from evenly sized triangles, subdivided from an icosahedron, which shades
more evenly than createSphere.
radiusX, radiusY and radiusZ stretch it per axis and fall back to radius when 0;
flat gives faceted shading.
The radii, the flat flag, the subdivisions, the side orientation and the shadow flag
The ico sphere mesh
Builds a flat disc of the given radius centered on the origin in the XY plane; arc below
1 leaves a pie slice, so 0.5 is a half disc.
The radius, the tessellation, the arc fraction, the side orientation and the shadow flag
The disc mesh
Builds a ring lying in the XZ plane around the origin: diameter is the ring's overall
diameter and thickness the diameter of its tube.
The diameter, the tube thickness, the tessellation, the side orientation and the shadow flag
The torus mesh
Builds a tube wound into a knot around the origin: p and q are how many times it winds
around the ring and through its hole, so 2 and 3 give the classic trefoil.
The radius, the tube radius, the segment counts, the winding numbers, the side orientation and the shadow flag
The torus knot mesh
Builds a flat filled polygon from its outline points, with optional holes, lying in the XZ
plane; a depth above 0 gives it thickness downward.
The points are 3D but only X and Z are used, and the outline must not cross itself.
The outline, the holes, the depth, the smoothing, the side orientation, the wrap flag and the shadow flag
The polygon mesh
Builds a solid by extruding a flat polygon, given by its outline points in the XZ plane with
optional holes, downward by depth.
The outline, the holes, the depth, the side orientation, the wrap flag and the shadow flag
The extruded mesh
Builds a tube of the given radius along a path of points; cap closes neither, one or both
ends, and arc below 1 leaves the tube open along its length.
The path, the radius, the tessellation, the cap mode, the arc fraction, the side orientation and the shadow flag
The tube mesh
Builds one of the fifteen built-in polyhedra by type, from tetrahedron (0) to elongated
pentagonal cupola (14), or your own from custom data.
sizeX, sizeY and sizeZ stretch it per axis and fall back to size when 0; flat gives
faceted shading.
The size and type, the custom data, the flat flag, the side orientation and the shadow flag
The polyhedron mesh
Builds a geodesic sphere, an icosahedron whose faces are subdivided into triangles as m and
n say, so the surface is made of near-equal triangles.
sizeX, sizeY and sizeZ stretch it per axis and fall back to size when 0.
The subdivision numbers, the sizes, the flat flag, the side orientation and the shadow flag
The geodesic mesh
Builds a Goldberg polyhedron, a ball made of hexagons and twelve pentagons like a football,
with m and n setting how many hexagons there are.
sizeX, sizeY and sizeZ stretch it per axis and fall back to size when 0.
The subdivision numbers, the sizes, the side orientation and the shadow flag
The Goldberg mesh
Builds a capsule, a cylinder with rounded ends, of the given height and radius along
orientation; radiusTop and radiusBottom size the two ends separately.
The orientation, the sizes, the subdivision counts, the side orientation and the shadow flag
The capsule mesh
const pill = bitbybit.babylon.meshBuilder.createCapsule({ orientation: [0, 1, 0], subdivisions: 2, tessellation: 16, height: 10, radius: 2, capSubdivisions: 6, radiusTop: 2, radiusBottom: 2, topCapSubdivisions: 6, bottomCapSubdivisions: 6, sideOrientation: Bit.Inputs.BabylonMesh.sideOrientationEnum.doubleside, enableShadows: true });
Builds a cylinder standing along Y, centered on the origin; different top and bottom diameters make a cone or a taper, and 0 closes an end to a point.
The height, the two diameters, the tessellation, the subdivisions, the side orientation and the shadow flag
The cylinder mesh
Sweeps a profile along a path: shape is the profile as points in the XY plane and path
the points it travels through, with scale and rotation in radians applied step by step
along the way.
closeShape joins the profile's ends, closePath joins the path's, and cap closes
neither, one or both ends.
The profile, the path, the scale, the rotation per step, the closing flags, the cap mode, the side orientation and the shadow flag
The swept mesh
const rail = bitbybit.babylon.meshBuilder.createExtrudedSahpe({ shape: [[-1, 0, 0], [1, 0, 0], [1, 1, 0], [-1, 1, 0]], path: [[0, 0, 0], [10, 0, 0], [10, 0, 10]], scale: 1, rotation: 0, closeShape: true, closePath: false, cap: 3, sideOrientation: Bit.Inputs.BabylonMesh.sideOrientationEnum.doubleside, enableShadows: true });
Builds a surface through several paths of points, joining neighboring paths with triangles, like cloth stretched over a set of lines.
closePath joins each path's ends, closeArray joins the last path back to the first, and
offset shifts how points pair up when only one path is given.
The paths, the closing flags, the offset, the updatable flag, the side orientation and the shadow flag
The ribbon mesh
const sheet = bitbybit.babylon.meshBuilder.createRibbon({ pathArray: [[[0, 0, 0], [10, 0, 0], [20, 0, 0]], [[0, 5, 5], [10, 5, 5], [20, 5, 5]]], closeArray: false, closePath: false, offset: 0, updatable: false, sideOrientation: Bit.Inputs.BabylonMesh.sideOrientationEnum.doubleside, enableShadows: true });
Revolves a profile around the Y axis, the way a lathe turns wood: shape is the profile as
points in the XY plane with X as the distance from the axis, radius pushes it outward, and
arc below 1 leaves the revolution open.
The profile, the radius, the tessellation, the arc fraction, the closed flag, the side orientation and the shadow flag
The lathe mesh
Builds a flat ground plane centered on the origin in the XZ plane, width along X and
height along Z, divided into a grid of subdivisionsX by subdivisionsY cells.
The width, the height, the subdivisions, the side orientation and the shadow flag
The ground mesh
Builds a flat rectangle centered on the origin in the XY plane, width along X and height
along Y, facing the Z axis.
The width, the height, the side orientation and the shadow flag
The plane mesh
BabylonJS's own mesh primitives, built straight into the scene as ready-to-render meshes rather than through a CAD kernel: boxes, spheres, discs, tori, polygons, tubes, polyhedra, capsules, cylinders, extrusions, ribbons, lathes and grounds. They are quick to make and cheap to draw but carry no exact geometry, so use the kernels when the shape must be measured, cut or exported. Every builder centers its mesh on the origin, sets
sideOrientationand registers it for shadows unlessenableShadowsis false.