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.
| Mesh( ): Mesh | Constructs an empty Mesh object. |
|---|
| trigons: Array<Trigon> | An array of the Trigons that make up the faces of the Mesh. |
|---|
| 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). 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. |
| inverseNormals(): Mesh | Swaps two vectors in every Trigon in the Mesh to effectively inverse the normal vector of each face. Returns this. See also: Trigon |
| qRotate(q: Quaternion): Mesh | Shorthand for quaternionRotate(). |
| quaternionRotate(q: Quaternion): Mesh | Rotates the Mesh by the given quaternion and returns this. |
| 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). |
| 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. |
| 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. |
| 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. 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. |
| 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). |
| 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. 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. |
| 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). |
| 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. |
| 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. |
| 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. |
| 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. |
Copyright © 2020 Trevor Richard