API Reference

Class List

pc.VertexFormat

A vertex format is a descriptor that defines the layout of vertex data inside a pc.VertexBuffer.

// Specify 3-component positions (x, y, z)
var vertexFormat = new pc.VertexFormat(graphicsDevice, [
    { semantic: pc.SEMANTIC_POSITION, components: 3, type: pc.ELEMENTTYPE_FLOAT32 },
]);
// Specify 2-component positions (x, y), a texture coordinate (u, v) and a vertex color (r, g, b, a)
var vertexFormat = new pc.VertexFormat(graphicsDevice, [
    { semantic: pc.SEMANTIC_POSITION, components: 2, type: pc.ELEMENTTYPE_FLOAT32 },
    { semantic: pc.SEMANTIC_TEXCOORD0, components: 2, type: pc.ELEMENTTYPE_FLOAT32 },
    { semantic: pc.SEMANTIC_COLOR, components: 4, type: pc.ELEMENTTYPE_UINT8, normalize: true }
]);

Summary

Details

Constructor

VertexFormat(graphicsDevice, description)

Returns a new pc.VertexFormat object.

// Specify 3-component positions (x, y, z)
var vertexFormat = new pc.VertexFormat(graphicsDevice, [
    { semantic: pc.SEMANTIC_POSITION, components: 3, type: pc.ELEMENTTYPE_FLOAT32 },
]);
// Specify 2-component positions (x, y), a texture coordinate (u, v) and a vertex color (r, g, b, a)
var vertexFormat = new pc.VertexFormat(graphicsDevice, [
    { semantic: pc.SEMANTIC_POSITION, components: 2, type: pc.ELEMENTTYPE_FLOAT32 },
    { semantic: pc.SEMANTIC_TEXCOORD0, components: 2, type: pc.ELEMENTTYPE_FLOAT32 },
    { semantic: pc.SEMANTIC_COLOR, components: 4, type: pc.ELEMENTTYPE_UINT8, normalize: true }
]);

Parameters

graphicsDevicepc.GraphicsDeviceThe graphics device used to manage this vertex format.
descriptionObject[]An array of vertex attribute descriptions.
description[].semanticNumberThe meaning of the vertex element. This is used to link the vertex data to a shader input. Can be:
  • pc.SEMANTIC_POSITION
  • pc.SEMANTIC_NORMAL
  • pc.SEMANTIC_TANGENT
  • pc.SEMANTIC_BLENDWEIGHT
  • pc.SEMANTIC_BLENDINDICES
  • pc.SEMANTIC_COLOR
  • pc.SEMANTIC_TEXCOORD0
  • pc.SEMANTIC_TEXCOORD1
  • pc.SEMANTIC_TEXCOORD2
  • pc.SEMANTIC_TEXCOORD3
  • pc.SEMANTIC_TEXCOORD4
  • pc.SEMANTIC_TEXCOORD5
  • pc.SEMANTIC_TEXCOORD6
  • pc.SEMANTIC_TEXCOORD7
If vertex data has a meaning other that one of those listed above, use the user-defined semantics: pc.SEMANTIC_ATTR0 to pc.SEMANTIC_ATTR15.
description[].componentsNumberThe number of components of the vertex attribute. Can be 1, 2, 3 or 4.
description[].typeNumberThe data type of the attribute. Can be:
  • pc.ELEMENTTYPE_INT8
  • pc.ELEMENTTYPE_UINT8
  • pc.ELEMENTTYPE_INT16
  • pc.ELEMENTTYPE_UINT16
  • pc.ELEMENTTYPE_INT32
  • pc.ELEMENTTYPE_UINT32
  • pc.ELEMENTTYPE_FLOAT32
description[].normalizeBooleanIf true, vertex attribute data will be mapped from a 0 to 255 range down to 0 to 1 when fed to a shader. If false, vertex attribute data is left unchanged. If this property is unspecified, false is assumed.