# modeling/geometries/geom3

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

Source:
See:
• geom3 for data structure information.
##### Examples
``colorize([0,0.5,1,0.6], cube()) // transparent ice cube``
``````{
"polygons": [
{"vertices": [[-1,-1,-1], [-1,-1,1], [-1,1,1], [-1,1,-1]]},
{"vertices": [[1,-1,-1], [1,1,-1], [1,1,1], [1,-1,1]]},
{"vertices": [[-1,-1,-1], [1,-1,-1], [1,-1,1], [-1,-1,1]]},
{"vertices": [[-1,1,-1], [-1,1,1], [1,1,1], [1,1,-1]]},
{"vertices": [[-1,-1,-1], [-1,1,-1], [1,1,-1], [1,-1,-1]]},
{"vertices": [[-1,-1,1], [1,-1,1], [1,1,1], [-1,1,1]]}
],
"transforms": [1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],
"color": [0,0.5,1,0.6]
}``````

### Methods

#### (static) clone(geometry) → {geom3}

Source:

Performs a shallow clone of the given geometry.

##### Parameters:
Name Type Description
`geometry` geom3

the geometry to clone

a new geometry

Type
geom3

#### (static) create(polygonsopt) → {geom3}

Source:

Create a new 3D geometry composed of the given polygons.

##### Parameters:
Name Type Attributes Description
`polygons` Array <optional>

list of polygons, or undefined

a new geometry

Type
geom3

#### (static) fromCompactBinary(data) → {geom3}

Source:

Construct a new 3D geometry from the given compact binary data.

##### Parameters:
Name Type Description
`data` TypedArray

compact binary data

a new geometry

Type
geom3

#### (static) fromPoints(listofpoints) → {geom3}

Source:

Construct a new 3D geometry from a list of points. The list of points should contain sub-arrays, each defining a single polygon of points. In addition, the points should follow the right-hand rule for rotation in order to define an external facing polygon.

##### Parameters:
Name Type Description
`listofpoints` Array

list of lists, where each list is a set of points to construct a polygon

a new geometry

Type
geom3

#### (static) invert(geometry) → {geom3}

Source:

Invert the given geometry, transposing solid and empty space.

##### Parameters:
Name Type Description
`geometry` geom3

the geometry to invert

a new geometry

Type
geom3

#### (static) isA(object) → {Boolean}

Source:

Determine if the given object is a 3D geometry.

##### Parameters:
Name Type Description
`object` Object

the object to interrogate

##### Returns:

true if the object matches a geom3

Type
Boolean

#### (static) toCompactBinary(geometry) → {TypedArray}

Source:

Return the given geometry in compact binary representation.

##### Parameters:
Name Type Description
`geometry` geom3

the geometry

##### Returns:

compact binary representation

Type
TypedArray

#### (static) toPoints(geometry) → {Array}

Source:

Return the given geometry as a list of points, after applying transforms. The returned array should not be modified as the points are shared with the geometry.

##### Parameters:
Name Type Description
`geometry` geom3

the geometry

##### Returns:

list of points, where each sub-array represents a polygon

Type
Array

#### (static) toPolygons(geometry) → {Array}

Source:

Produces an array of polygons from the given geometry, after applying transforms. The returned array should not be modified as the polygons are shared with the geometry.

##### Example
``let sharedpolygons = toPolygons(geometry)``
##### Parameters:
Name Type Description
`geometry` geom3

the geometry

##### Returns:

an array of polygons

Type
Array

#### (static) toString(geometry) → {String}

Source:

Create a string representing the contents of the given geometry.

##### Example
``console.out(toString(geometry))``
##### Parameters:
Name Type Description
`geometry` geom3

the geometry

##### Returns:

a representative string

Type
String

#### (static) transform(matrix, geometry) → {geom3}

Source:

Transform the given geometry using the given matrix. This is a lazy transform of the polygons, as this function only adjusts the transforms. See applyTransforms() for the actual application of the transforms to the polygons.

##### Example
``let newgeometry = transform(fromXRotation(degToRad(90)), geometry)``
##### Parameters:
Name Type Description
`matrix` mat4

the matrix to transform with

`geometry` geom3

the geometry to transform

a new geometry

Type
geom3

#### (static) validate(object)

Source:

Determine if the given object is a valid 3D geometry. Checks for valid data structure, convex polygon faces, and manifold edges.

If the geometry is not valid, an exception will be thrown with details of the geometry error.

##### Parameters:
Name Type Description
`object` Object

the object to interrogate

##### Throws:

error if the geometry is not valid

Type
Error