modeling/extrusions/slice

Represents a 3D geometry consisting of a list of edges.

Source:
See:
  • slice for data structure information.

Methods

(static) calculatePlane(slice) → {plane}

Source:

Calculate the plane of the given slice. NOTE: The slice (and all points) are assumed to be planar from the beginning.

Example
let myplane = calculatePlane(slice)
Parameters:
Name Type Description
slice slice

the slice

Returns:

the plane of the slice

Type
plane

(static) clone(outopt, slice) → {slice}

Source:

Create a deep clone of the given slice.

Parameters:
Name Type Attributes Description
out slice <optional>

receiving slice

slice slice

slice to clone

Returns:

a new slice

Type
slice

(static) create() → {slice}

Source:

Creates a new empty slice.

Returns:

a new slice

Type
slice

(static) equals(a, b) → {Boolean}

Source:

Determine if the given slices have the same edges.

Parameters:
Name Type Description
a slice

the first slice to compare

b slice

the second slice to compare

Returns:

true if the slices are equal

Type
Boolean

(static) fromPoints(points) → {slice}

Source:

Create a slice from the given points.

Example
const points = [
  [0,  0],
  [0, 10],
  [0, 10]
]
const slice = fromPoints(points)
Parameters:
Name Type Description
points Array

list of points, where each point is either 2D or 3D

Returns:

a new slice

Type
slice

(static) fromSides(sides) → {slice}

Source:

Create a slice from the given sides (see geom2).

Example
const myshape = circle({radius: 10})
const slice = fromSides(geom2.toSides(myshape))
Parameters:
Name Type Description
sides Array

list of sides from geom2

Returns:

a new slice

Type
slice

(static) isA(object) → {Boolean}

Source:

Determine if the given object is a slice.

Parameters:
Name Type Description
object slice

the object to interrogate

Returns:

true if the object matches a slice

Type
Boolean

(static) reverse(outopt, slice) → {slice}

Source:

Reverse the edges of the given slice.

Parameters:
Name Type Attributes Description
out slice <optional>

receiving slice

slice slice

slice to reverse

Returns:

reverse of the slice

Type
slice

(static) toEdges(slice) → {Array}

Source:

Produces an array of edges from the given slice. The returned array should not be modified as the data is shared with the slice.

Example
let sharededges = toEdges(slice)
Parameters:
Name Type Description
slice slice

the slice

Returns:

an array of edges, each edge contains an array of two points (3D)

Type
Array

(static) toPolygons(slice) → {Array}

Source:

Return a list of polygons which are enclosed by the slice.

Parameters:
Name Type Description
slice slice

the slice

Returns:

a list of polygons (3D)

Type
Array

(static) toString(slice) → {String}

Source:
Parameters:
Name Type Description
slice slice

the slice

Returns:

the string representation

Type
String

(static) transform(matrix, slice) → {slice}

Source:

Transform the given slice using the given matrix.

Example
let matrix = mat4.fromTranslation([1, 2, 3])
let newslice = transform(matrix, oldslice)
Parameters:
Name Type Description
matrix mat4

transform matrix

slice slice

slice to transform

Returns:

the transformed slice

Type
slice