API

Provided Polyhedra

Polyhedra Provided by Number

There are fifteen polyhedra that can be created by setting their type number from 0 to 14. These are:

typenamenumber of faces
0
Tetrahedron
4
1
Octahedron
8
2
Dodecahedron
12
3
Icosahedron
20
4
Rhombicuboctahedron
26
5
Triangular Prism
5
6
Pentagonal Prism
7
7
Hexagonal Prism
8
8
Square Pyramid (J1)
5
9
Pentagonal Pyramid (J2)
6
10
Triangular Dipyramid (J12)
6
11
Pentagonal Dipyramid (J13)
10
12
Elongated Square Dipyramid (J15)
12
13
Elongated Pentagonal Dipyramid (J16)
15
14
Elongated Pentagonal Cupola (J20)
22

MeshBuilder

usage :

import { MeshBuilder } from "@babylonjs/core/Meshes/meshBuilder";
const polyhedron = MeshBuilder.CreatePolyhedron("oct", options, scene); //scene is optional and defaults to the current scene
optionvaluedefault value
type
(number) polyhedron type in the range [0,14]
0
size
(number) polyhedron size
1
sizeX
(number) X polyhedron size, overwrites the size property
1
sizeY
(number) Y polyhedron size, overwrites the size property
1
sizeZ
(number) Z polyhedron size, overwrites the size property
1
custom
(polygonObjectReference) a polyhedron object, overwrites the type property
null
faceColors
(Color4[]) array of Color4, one per face
Color4(1, 1, 1, 1) for each side
faceUV
(Vector4[]) array of Vector4, one per face
UVs(0, 0, 1, 1) for each side
flat
(boolean) if false, a polyhedron has a single global face, faceUV and faceColors are ignored
true
updatable
(boolean) true if the mesh is updatable
false
sideOrientation
(number) side orientation
DEFAULTSIDE

To understand how to set faceUV or faceColors, please read about Face Colors and Textures for a Box taking into account the right number of faces of your polyhedron, instead of only 6 for a box.

Examples

The full set of 15: Full Set Of 15 Polyhedra Dodecahedron with FaceUVs: Dodecahedron with FaceUVs

Mesh

usage :

import { Mesh } from "@babylonjs/core/Meshes/mesh";
const polyhedron = Mesh.CreatePolyhedron("oct", options, scene); //scene is optional and defaults to the current scene

This is the same format as that for MeshBuilder.