Table of contents

There are fifteen polyhedra that can be created simply by setting its type number from 0 to 14, and one, the icosphere that is created by name to which more variations can be applied. However there are plenty more to choose from, just follow the instructions under Custom Polyhedra.

Example :

```
var octahedron = BABYLON.MeshBuilder.CreatePolyhedron("oct", {type: 1, size: 3}, scene);
```

Properties, all optional :

property | value | default 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.

type | name | side number |
---|---|---|

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 |

If you need to use a custom polyhedron visit https://www.babylonjs-playground.com/#21QRSK#15 -

: minimize the code editor by unchecking box by Editor under Settings and note the polyhedron names under the mouse pointer. The data for each name can be found in the polyhedra.js file here https://github.com/BabylonJS/Extensions/tree/master/Polyhedron Find the name and copy/paste the wanted polyhedron object in your code like this :

```
var heptagonalPrism = { "name":"Heptagonal Prism", "category":["Prism"], "vertex":[[0,0,1.090071],[0.796065,0,0.7446715],[-0.1498633,0.7818315,0.7446715],[-0.7396399,-0.2943675,0.7446715],[0.6462017,0.7818315,0.3992718],[1.049102,-0.2943675,-0.03143449],[-0.8895032,0.487464,0.3992718],[-0.8658909,-0.6614378,-0.03143449],[0.8992386,0.487464,-0.3768342],[0.5685687,-0.6614378,-0.6538232],[-1.015754,0.1203937,-0.3768342],[-0.2836832,-0.8247995,-0.6538232],[0.4187054,0.1203937,-0.9992228],[-0.4335465,-0.042968,-0.9992228]],
"face":[[0,1,4,2],[0,2,6,3],[1,5,8,4],[3,6,10,7],[5,9,12,8],[7,10,13,11],[9,11,13,12],[0,3,7,11,9,5,1],[2,4,8,12,13,10,6]]};
var mesh = BABYLON.MeshBuilder.CreatePolyhdron("h", {custom: heptagonalPrism}, scene);
```

This a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.

```
var icosphere = BABYLON.MeshBuilder.CreateIcoSphere("ico", {radius: 5, radiusY: 8, subdivisions: 6}, scene);
```

Properties, all optional :

property | value | default value |
---|---|---|

radius | (number) radius |
1 |

radiusX | (number) the X radius, overwrites the radius value |
radius |

radiusY | (Vector3) the Y radius, overwrites the radius value |
radius |

radiusZ | (number) the Z radius, overwrites the radius value |
radius |

subdivisions | (number) the number of subdivisions |
4 |

flat | (boolean) if true, the mesh faces have their own normals |
true |

updatable | (boolean) true if the mesh is updatable |
false |

sideOrientation | (number) side orientation |
DEFAULTSIDE |

An example of an IcoSphere: http://www.babylonjs-playground.com/#24DUYD#1 -

and one with animation: http://www.babylonjs-playground.com/#E3TVT#1 -

Where a polyhedral 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

Set Shapes

Parametric Shapes

Ribbons In Detail

Maths Makes Ribbons

Decals