module:extras/polyhedra.Polyhedra
### new module:extras/polyhedra.Polyhedra()
Contains helper methods for generating the five platonic solids and other polyhedra.
Methods
- dodecahedron
Generates a mesh of a regular dodecahedron or a sphere based on that solid. - dodecahedronFaces
Gets the vertices of a dodecahedron with maximum radius 1. - dodecahedronFacesCompact
Gets a more compact representation of the vertices of a dodecahedron with maximum radius 1. - hexahedron
Generates a mesh of a regular hexahedron (cube) or a sphere based on that solid. - hexahedronFaces
Gets the vertices of a hexahedron (cube) with maximum radius 1. - hexahedronFacesCompact
Gets a more compact representation of the vertices of a hexahedron (cube) with maximum radius 1. - icosahedron
Generates a mesh of a regular icosahedron or a sphere based on that solid. - icosahedronFaces
Gets the vertices of a regular icosahedron with maximum radius 1. - makeSphere
Modifies the vertices and indices of a solid to generate an approximation of a sphere. - normDistances
Normalizes the distance from the origin to each vertex in the given array to a fixed radius. - octahedron
Generates a mesh of a regular octahedron or a sphere based on that solid. - octahedronFaces
Gets the vertices of a regular octahedron with radius 1. - tetrahedron
Generates a mesh of a regular tetrahedron or a sphere based on that solid. - tetrahedronFaces
Gets the vertices of a tetrahedron with radius 1.
### (static) module:extras/polyhedra~Polyhedra.dodecahedron(radius, level)
Generates a mesh of a regular dodecahedron or a sphere based on that solid.
Parameters
radius
(Type: number)
Maximum radius from the center of the solid to one of its vertices.level
(Type: number)
If 0 or less, generates the solid as is. If 1 or greater, subdivides each triangle on the solid’s surface into smaller triangles and makes them bulge out to form an approximation of a sphere (the bigger the number, the smaller the triangles).
Return Value
The generated solid. (Type: MeshBuffer)
### (static) module:extras/polyhedra~Polyhedra.dodecahedronFaces()
Gets the vertices of a dodecahedron with maximum radius 1.
Return Value
A two-element array. The first element contains an array of the vertices that make up the solid (each vertex’s X, Y, and Z coordinates are stored as three elements of that array), and the second element contains an array of vertex indices (multiplying each element by 3 will get the index to the first coordinate of the corresponding vertex in the first array). (Type: Array.<Array.<number»)
### (static) module:extras/polyhedra~Polyhedra.dodecahedronFacesCompact()
Gets a more compact representation of the vertices of a dodecahedron with maximum radius 1.
Return Value
A two-element array. The first element contains an array of the vertices that make up the solid (each vertex’s X, Y, and Z coordinates are stored as three elements of that array), and the second element contains an array of vertex indices (multiplying each element by 3 will get the index to the first coordinate of the corresponding vertex in the first array). (Type: Array.<Array.<number»)
### (static) module:extras/polyhedra~Polyhedra.hexahedron(radius, level)
Generates a mesh of a regular hexahedron (cube) or a sphere based on that solid.
Parameters
radius
(Type: number)
Maximum radius from the center of the solid to one of its vertices.level
(Type: number)
If 0 or less, generates the solid as is. If 1 or greater, subdivides each triangle on the solid’s surface into smaller triangles and makes them bulge out to form an approximation of a sphere (the bigger the number, the smaller the triangles).
Return Value
The generated solid. (Type: MeshBuffer)
### (static) module:extras/polyhedra~Polyhedra.hexahedronFaces()
Gets the vertices of a hexahedron (cube) with maximum radius 1.
Return Value
A two-element array. The first element contains an array of the vertices that make up the solid (each vertex’s X, Y, and Z coordinates are stored as three elements of that array), and the second element contains an array of vertex indices (multiplying each element by 3 will get the index to the first coordinate of the corresponding vertex in the first array). (Type: Array.<Array.<number»)
### (static) module:extras/polyhedra~Polyhedra.hexahedronFacesCompact()
Gets a more compact representation of the vertices of a hexahedron (cube) with maximum radius 1.
Return Value
A two-element array. The first element contains an array of the vertices that make up the solid (each vertex’s X, Y, and Z coordinates are stored as three elements of that array), and the second element contains an array of vertex indices (multiplying each element by 3 will get the index to the first coordinate of the corresponding vertex in the first array). (Type: Array.<Array.<number»)
### (static) module:extras/polyhedra~Polyhedra.icosahedron(radius, level)
Generates a mesh of a regular icosahedron or a sphere based on that solid.
Parameters
radius
(Type: number)
Maximum radius from the center of the solid to one of its vertices.level
(Type: number)
If 0 or less, generates the solid as is. If 1 or greater, subdivides each triangle on the solid’s surface into smaller triangles and makes them bulge out to form an approximation of a sphere (the bigger the number, the smaller the triangles).
Return Value
The generated solid. (Type: MeshBuffer)
### (static) module:extras/polyhedra~Polyhedra.icosahedronFaces()
Gets the vertices of a regular icosahedron with maximum radius 1.
Return Value
A two-element array. The first element contains an array of the vertices that make up the solid (each vertex’s X, Y, and Z coordinates are stored as three elements of that array), and the second element contains an array of vertex indices (multiplying each element by 3 will get the index to the first coordinate of the corresponding vertex in the first array). (Type: Array.<Array.<number»)
### (static) module:extras/polyhedra~Polyhedra.makeSphere(vi, radius, level)
Modifies the vertices and indices of a solid to generate an approximation of a sphere.
Parameters
vi
(Type: Array.<Array.<number»)
A two-element array. The first element contains an array of the vertices that make up the solid (each vertex’s X, Y, and Z coordinates are stored as three elements of that array), and the second element contains an array of vertex indices (multiplying each element by 3 will get the index to the first coordinate of the corresponding vertex in the first array).radius
(Type: number)
Maximum radius from the center of the solid to one of its vertices.level
(Type: number)
If 0 or less, generates the solid as is. If 1 or greater, subdivides each triangle on the solid’s surface into smaller triangles and makes them bulge out to form an approximation of a sphere (the bigger the number, the smaller the triangles).
Return Value
The “vi” parameter, which will likely be modified. (Type: Array.<Array.<number»)
### (static) module:extras/polyhedra~Polyhedra.normDistances(vertices, radius)
Normalizes the distance from the origin to each vertex in the given array to a fixed radius.
Parameters
vertices
(Type: Array.<number>)
An array of vertices, where each vertex’s X, Y, and Z coordinates are stored as three elements of that array.radius
(Type: number)
Distance from the origin where each vertex will be normalized to.
Return Value
Return value. (Type: Object)
### (static) module:extras/polyhedra~Polyhedra.octahedron(radius, level)
Generates a mesh of a regular octahedron or a sphere based on that solid.
Parameters
radius
(Type: number)
Maximum radius from the center of the solid to one of its vertices.level
(Type: number)
If 0 or less, generates the solid as is. If 1 or greater, subdivides each triangle on the solid’s surface into smaller triangles and makes them bulge out to form an approximation of a sphere (the bigger the number, the smaller the triangles).
Return Value
The generated solid. (Type: MeshBuffer)
### (static) module:extras/polyhedra~Polyhedra.octahedronFaces()
Gets the vertices of a regular octahedron with radius 1.
Return Value
A two-element array. The first element contains an array of the vertices that make up the solid (each vertex’s X, Y, and Z coordinates are stored as three elements of that array), and the second element contains an array of vertex indices (multiplying each element by 3 will get the index to the first coordinate of the corresponding vertex in the first array). (Type: Array.<Array.<number»)
### (static) module:extras/polyhedra~Polyhedra.tetrahedron(radius, level)
Generates a mesh of a regular tetrahedron or a sphere based on that solid.
Parameters
radius
(Type: number)
Maximum radius from the center of the solid to one of its vertices.level
(Type: number)
If 0 or less, generates the solid as is. If 1 or greater, subdivides each triangle on the solid’s surface into smaller triangles and makes them bulge out to form an approximation of a sphere (the bigger the number, the smaller the triangles).
Return Value
The generated solid. (Type: MeshBuffer)
### (static) module:extras/polyhedra~Polyhedra.tetrahedronFaces()
Gets the vertices of a tetrahedron with radius 1.
Return Value
A two-element array. The first element contains an array of the vertices that make up the solid (each vertex’s X, Y, and Z coordinates are stored as three elements of that array), and the second element contains an array of vertex indices (multiplying each element by 3 will get the index to the first coordinate of the corresponding vertex in the first array). (Type: Array.<Array.<number»)