Class Mesh2

The base class for 2D triangle meshes. This class extends Node2 so it can be added directly to the GopherGfx 2D scene graph. It is possible to create a new "empty" Mesh2 and then add triangles to it. Most of the routines in the Geometry2Factory do this. Use those to create a new Mesh2 for simple geometric shapes like circles and rectangles. Those routines also provide good examples of how to create your own custom mesh via code if you wish to create something more complex via programming.

Hierarchy

Constructors

Properties

_localBoundingBox: BoundingBox2

Bounding box in this transform's local coordinate space

_localBoundingCircle: BoundingCircle

Bounding circle in this transform's local coordinate space

_position: Vector2

Vector2 representing the position

_rotation: number

Rotation of the transform in radians

_scale: Vector2

Vector2 representing the scale

_shear: null | Vector2
_worldBoundingBox: BoundingBox2

Bounding box in the world coordinate space

_worldBoundingCircle: BoundingCircle

Bounding box in the world coordinate space

boundingBox: BoundingBox2

Bounding box in vertex coordinate space

boundingCircle: BoundingCircle

Bounding circle in vertex coordinate space

children: Node2[]

Array of children for this transform

colorBuffer: null | WebGLBuffer

Buffer that stores the color of each vertex.

customBuffers: (null | WebGLBuffer)[]

Array of buffers that store custom information for each vertex.

gl: WebGL2RenderingContext
hasVertexColors: boolean

Flag that determines whether to use vertex colors.

layer: number

Integer representing the layer of this transform

localBoundsDirty: boolean
localMatrixDirty: boolean
localMatrixUpdated: boolean
localToParentMatrix: Matrix3

Matrix3 representing the transformation matrix in local space

localToWorldMatrix: Matrix3

Matrix3 representing the transformation matrix in world space

material: Material2

Material to draw the Mesh2 with.

parent: null | Node2

Parent transform for this transform

positionBuffer: null | WebGLBuffer

Buffer that stores the position of each vertex.

texCoordBuffer: null | WebGLBuffer

Buffer that stores the texture (UV) coordinate at each vertex.

vertexCount: number

Number of vertices in the Mesh2.

visible: boolean

Boolean indicating whether this transform should be rendered

worldBoundsDirty: boolean
worldMatrixDirty: boolean

Accessors

  • get rotation(): number
  • Returns number

  • set rotation(value: number): void
  • Parameters

    • value: number

    Returns void

Methods

  • Compute the 2D Bounds (both bounding box and bounding circle) of the Mesh2.

    Parameters

    • vertices: null | number[] | Vector2[]

      Vertices to include in the Mesh2. If empty, defaults to the object's current vertices.

    Returns void

  • Get the vertex colors of the Mesh2

    Returns

    • Returns the array of colors as numbers (not Color objects)

    Returns number[]

  • Get the values in one of the Mesh2's custom buffers

    Returns

    • Returns the array of numbers stored in the buffer

    Parameters

    • bufferIndex: number

      The index number of the buffer to get.

    • numValues: number

    Returns number[]

  • Get the texture coordinates of the Mesh2

    Returns

    • Returns the array of texture (UV) coordinates as numbers (not Vector2 objects)

    Returns number[]

  • Get the vertices of the Mesh2

    Returns

    • Returns the array of vertices as numbers (not Vector2 objects)

    Returns number[]

  • Checks if this Node2 intersects another Node2, using either a BoundingCircle or AxisAlignedBoundingBox

    Returns

    A boolean indicating whether the two objects intersect

    Parameters

    • other: Node2

      The Node2 to check for intersection with

    • mode: IntersectionMode2 = IntersectionMode2.BOUNDING_CIRCLE

      The IntersectionMode2 to use for the comparison (default: BOUNDING_CIRCLE)

    • space: CoordinateSpace2 = CoordinateSpace2.LOCAL_SPACE

      The CoordinateSpace2 to use for the comparison (default: LOCAL_SPACE)

    Returns boolean

  • Removes the current Node2 from its parent

    Returns

    True if the Node2 was successfully removed, false otherwise

    Returns boolean

  • Removes the specified child Node2 from the current Node2

    Returns

    The removed Node2, or null if it was not found

    Parameters

    • child: Node2

      The child Node2 to remove

    Returns null | Node2

  • Set the color at each vertex of the Mesh2.

    Parameters

    • colors: number[] | Color[]
    • usage: 35044 = ...

      Intended usage (static or dynamic) of the Mesh2's vertex colors.

    Returns void

  • Sets a custom buffer from an input array.

    Parameters

    • bufferIndex: number

      The index number of the buffer to set.

    • values: number[]

      Array of numerical values to store in the buffer.

    • usage: 35044 = ...

      Intended usage (static or dynamic) of the Mesh2's buffer.

    Returns void

  • Set the texture (UV) coordinates at each vertex of the Mesh2.

    Parameters

    • texCoords: number[] | Vector2[]

      Array of texture coordinates.

    • usage: 35044 = ...

      Intended usage (static or dynamic) of the Mesh2's UV coordinates.

    Returns void

  • Set the vertices of the Mesh2. Vertices should be in normalized device coordinates [-1, 1].

    Parameters

    • vertices: number[] | Vector2[]

      Array of vertices.

    • usage: 35044 = ...

      Intended usage (static or dynamic) of the Mesh2's vertices.

    Returns void

  • Traverses the scene graph starting from the current Node2 object

    Parameters

    • parentMatrixDirty: boolean = false

    Returns void

Generated using TypeDoc