Engine API Reference - v2.6.1
    Preparing search index...

    Class VertexFormat

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

    Index

    Constructors

    • Create a new VertexFormat instance.

      Parameters

      • graphicsDevice: GraphicsDevice

        The graphics device used to manage this vertex format.

      • description: AttributeDescription[]

        An array of vertex attribute descriptions.

      • OptionalvertexCount: number

        When specified, vertex format will be set up for non-interleaved format with a specified number of vertices. (example: PPPPNNNNCCCC), where arrays of individual attributes will be stored one right after the other (subject to alignment requirements). Note that in this case, the format depends on the number of vertices, and needs to change when the number of vertices changes. When not specified, vertex format will be interleaved. (example: PNCPNCPNCPNC).

      Returns VertexFormat

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

    Methods