Skip to main content
Version: 0.11.0

UeVertexFormat

The UeVertexFormat class defines the layout of vertex data for a UeGeometry. It acts as a chainable builder for setting attributes like position, normal, UV, color, and custom fields.

Constructor

new UeVertexFormat()

🛠️ Usage Example

// Create the standard PNUTC format (Position, Normal, UV, Tangent, Color)
const format = new UeVertexFormat().position().normal().uv().tangent().color().build();

Global Formats

Unique Engine provides pre-defined global vertex formats for common use cases:

  • global.UE_VFORMAT_PNUTCB: Extended format with Position, Normal, UV, Tangent, Color, and Bones (Indices and Weights). Used for skinned meshes.
  • global.UE_VFORMAT_PNUTC: Standard format with Position, Normal, UV, Tangent, and Color.
  • global.UE_VFORMAT_PNUC: Format with Position, Normal, UV, and Color (no tangents).
  • global.UE_VFORMAT_PUC: Format with Position, UV, and Color.
  • global.UE_VFORMAT_PU: Minimal format with Position and UV.

🧩 Methods

position()

Adds a 3D position attribute (vertex_format_add_position_3d).

normal()

Adds a normal vector attribute (vertex_format_add_normal).

uv()

Adds a UV texture coordinate attribute (vertex_format_add_texcoord).

tangent()

Adds a tangent vector attribute as a custom float4 (XYZ for direction, W for handedness). This is required for PBR materials and normal mapping.

color()

Adds a vertex color attribute (vertex_format_add_color).

bones()

Adds two custom float4 attributes for bone indices and bone weights. Required for skinned meshes and skeletal animation.

custom(name, type)

Adds a custom vertex attribute.

  • name – Name of the attribute, for reference
  • type – Type of the attribute (e.g. vertex_type_float2)
build()

Finalizes the vertex format and returns the current object. Internally calls vertex_format_begin() and vertex_format_end().

dispose()

Cleanup the vertex format resource

toJSON()

Returns an object representing this entity's properties. Not all props may be included.