Type alias AttributeOptions

AttributeOptions: {
    arrayBuffer: ArrayType;
    format: GPUVertexFormat;
    itemCount: number;
    itemSize: number;
    label?: string;
    shaderLocation: number;
}

Attribute constructor parameters

Type declaration

  • arrayBuffer: ArrayType
  • format: GPUVertexFormat
  • itemCount: number

    The number of items in the attribute. For example, given a vertex attribute this would the number of vertices stored in the buffer.

    e.g.

    const triangleVertices = new Float32Array([
    -1.0, -1.0, 1.0, -1.0, 1.0, 1.0,
    ]);

    const posAttribute = new Attribute({
    // other stuff
    format: "float32x2",
    itemCount: triangleVertices.length / 2,
    });

    would have an itemCount of 3, because three 2D vertices are contained in the buffer.

  • itemSize: number

    The number of components in each item of the attribute e.g.

    @location(0) pos: vec3<f32>
    

    would have an itemSize of 3.

  • Optional label?: string
  • shaderLocation: number

    The value of the location directive of the attribute in the shader e.g.

    @location(0) pos: vec3<f32>
    

    would have a shaderLocation of 0.

Generated using TypeDoc