module:extras/convex
The extras/convex.js
module.
To import all symbols in this module, either of the following can be used:
import * from "extras/convex.js"; // -- or -- import * as CustomModuleName from "extras/convex.js";
Methods
- createConvexHull
Generates the convex hull of a set of 3-dimensional points, that is, the smallest convex set that contains all the points given. - planePointsToConvexHull
Generates a convex hull of the half-space representation of several planes. - randomConvexPolyhedron
Generates a mesh buffer of a convex polyhedron at random.
### (static) module:extras/convex.createConvexHull(points, [flat], [inside])
Generates the convex hull of a set of 3-dimensional points, that is, the smallest convex set that contains all the points given.
Parameters
points
(Type: Array.<number>)
An array of 3-element vectors each identifying a 3-dimensional point.flat
(Type: boolean) (optional)
If true, will generate normals such that the figure will be flat shaded; otherwise, will generate normals such that the figure will be smooth shaded.inside
(Type: boolean) (optional)
If true, the normals generated by this method will point inward; otherwise, outward. Should normally be false unless the figure will be viewed from the inside.
Return Value
The generated convex hull. (Type: MeshBuffer)
### (static) module:extras/convex.planePointsToConvexHull(planepoints)
Generates a convex hull of the half-space representation of several planes. Each plane is defined by the triangle it lies on.
Parameters
planepoints
(Type: Array.<Array.<number»)
An array of planes. Each plane is defined by three points that form a triangle that lies on the plane. The triangle’s normal vector will point outward, meaning all points on the side pointed to by the normal vector will be “outside” the plane, and other points will be “inside” the plane.
Return Value
The generated convex hull. (Type: MeshBuffer)
### (static) module:extras/convex.randomConvexPolyhedron(avgsize, maxfaces)
Generates a mesh buffer of a convex polyhedron at random.
Parameters
avgsize
(Type: number)
Average size of the polyhedron generated.maxfaces
(Type: number)
Maximum number of faces for the convex polyhedron.
Return Value
The resulting polyhedron. (Type: MeshBuffer)