Mesh

Home

A Mesh is an object used to represent a group of points in 3D space that can be manipulated as a whole. In Urchin, all Mesh objects are made up of an array of Trigon objects.

Mesh objects can be constructed and added to one or more MeshUrbjects to be rendered. When a MeshUrbject is rotated or transformed in some way, the underlying Mesh data is read, but not modified. This promotes a system that is resistant to Round-off Errors.

See also: Trigon, MeshUrbject

Constructors

Mesh( ): Mesh Constructs an empty Mesh object.

Variables

Public Variables

trigons: Array<Trigon> An array of the Trigons that make up the faces of the Mesh. See also: Trigon

Functions

Public Functions

addTrigon(t: Trigon | Array<Trigon>): Trigon | Array<Trigon> Adds the given Trigon or Array of Trigons to the Mesh and returns the added Trigon(s). Note: All Trigons are copied before they are added to the Mesh.

See also: Trigon
copy(): Mesh Returns a copy of the Mesh.
generateFromArrayData(v: Array<number>): Mesh Generates Trigons from the Array of vector components given (Every 3 numbers in the given array should make up a 3D point in the order: X, Y, Z, and every 3 Vectors make up a different Trigon) and adds them to the Mesh. Returns this. See also: Trigon, Vector
inverseNormals(): Mesh Swaps two vectors in every Trigon in the Mesh to effectively inverse the normal vector of each face. Returns this. Note: An inverse Mesh is essentially "inside-out" compared to its original version.

See also: Trigon
qRotate(q: Quaternion): Mesh Shorthand for quaternionRotate().
quaternionRotate(q: Quaternion): Mesh Rotates the Mesh by the given quaternion and returns this. See also: Quaternion
rotateAxis(axis: number | Vector, angle: number): Mesh Rotates the Mesh around the given axis by the given angle in radians and returns this. One of the following number constants can also be given as the axis: (Vector.X_AXIS, Vector.Y_AXIS, Vector.Z_AXIS). See also: Vector
rotateX(angle: number): Mesh Rotates the Mesh around the X-Axis by the given angle in radians and returns this.
rotateY(angle: number): Mesh Rotates the Mesh around the Y-Axis by the given angle in radians and returns this.
rotateZ(angle: number): Mesh Rotates the Mesh around the Z-Axis by the given angle in radians and returns this.
scale(s: number | Vector): Mesh Scales the Mesh by the given number or vector and returns this. See also: Vector
transform(M: Array<Array<number>>): Mesh Transforms the Mesh by the given 3 or 4 dimensional transformation matrix and returns this.
translate(v: Vector): Mesh Translates the Mesh by the given vector and returns this. See also: Vector

Static Functions

Mesh.addTrigon(m: Mesh, t: Trigon | Array<Trigon>): Trigon | Array<Trigon> Adds the given Trigon or Array of Trigons to a copy of the Mesh and returns the new Mesh. Note: All Trigons are copied before they are added to the Mesh.

See also: Trigon
Mesh.circle(options?: { resolution?: number, radius?: number }): Mesh Constructs a "circle" with the given radius at the origin, facing in the positive Z-Axis. radius has a default value of 0.5. resolution has a default value of 16 and a minimum value of 3 and determines the number of Trigons that will make up the circle. Note: This construction can also be classified as a unit polygon with the number of sides equal to the resolution.
Mesh.copy(m: Mesh): Mesh Returns a copy of the given Mesh or object that has all of the public attributes of a Mesh.
Mesh.cube(): Mesh Constructs a unit cube Mesh centered at the Origin.
Mesh.cylinder(options?: { resolution?: number, outerRadius?: number, innerRadius?: number, height?: number}): Mesh Constructs a cylinder Mesh with the given values. The resolution works the similar to Mesh.circle() to determine the number of sides for the cylinder and has a default value of 16 and a minimum value of 3. outerRadius determines the outer radius of the cylinder and has a default value of 0.5. If innerRadius is set, a tube-like Mesh is constructed instead, with the inner radius equal to the value given. The height value determines the height of the cylinder and has a default value of 1.
Mesh.generateFromArrayData(v: Array<number>): Mesh Returns a new Mesh with generated Trigons from the Array of vector components given (Every 3 numbers in the given array should make up a 3D point in the order: X, Y, Z, and every 3 Vectors make up a different Trigon). See also: Trigon, Vector
Mesh.inverseNormals(m: Mesh): Mesh Creates a copy of the given Mesh and swaps two vectors in every Trigon in the Mesh to effectively inverse the normal vector of each face. Note: An inverse Mesh is essentially "inside-out" compared to its original version.

See also: Trigon
Mesh.plane(): Mesh Constructs a unit plane Mesh from two Trigons, centered at the origin . By default, the plane is facing in the positive Z-Axis.
Mesh.qRotate(m: Mesh, q: Quaternion): Mesh Shorthand for Mesh.quaternionRotate().
Mesh.quaternionRotate(m: Mesh, q: Quaternion): Mesh Rotates a copy of the Mesh by the given quaternion and returns the new Mesh. See also: Quaternion
Mesh.rotateAxis(m: Mesh, axis: number | Vector, angle: number): Mesh Rotates a copy of the Mesh around the given axis by the given angle in radians and returns the new Mesh. One of the following number constants can also be given as the axis: (Vector.X_AXIS, Vector.Y_AXIS, Vector.Z_AXIS). See also: Vector
Mesh.rotateX(m: Mesh, angle: number): Mesh Rotates a copy of the Mesh around the X-Axis by the given angle in radians and returns the new Mesh.
Mesh.rotateY(m: Mesh, angle: number): Mesh Rotates a copy of the Mesh around the Y-Axis by the given angle in radians and returns the new Mesh.
Mesh.rotateZ(m: Mesh, angle: number): Mesh Rotates a copy of the Mesh around the Z-Axis by the given angle in radians and returns the new Mesh.
Mesh.scale(m: Mesh, s: number | Vector): Mesh Scales a copy of the Mesh by the given number or vector and returns the new Mesh. See also: Vector
Mesh.sphere(options?: { subdivisions?: number, radius?: number }): Mesh Constructs an ico-sphere with the given radius or a default radius of 0.5. The subdivisions attribute has a default value of 3 and a minimum value of 1 and dictates how many times the constructor will iteratively refine a Geodesic Polyhedron which adds 3-times the Trigon count each iteration. Trigon
Mesh.transform(m: Mesh, M: Array<Array<number>>): Mesh Transforms a copy of the Mesh by the given 3 or 4 dimensional transformation matrix and returns the new Mesh.
Mesh.translate(m: Mesh, v: Vector): Mesh Translates a copy of the Mesh by the given vector and returns the new Mesh. See also: Vector
Mesh.uvSphere(options?: { resolution?: number, radius?: number } ): Mesh Constructs a UV Sphere with the given radius or a default radius of 0.5. The resolution attribute has a default value of 16 and a minimum value of 3 and works similarly to the resolution in Mesh.circle() by determining the amount of sides to an XY-plane cross-section of the sphere. Note: By default, the north and south poles of the sphere are located on the Z-Axis.

Home

Copyright © 2020 Trevor Richard