Function makeTypedArrayViews

  • Creates a set of named TypedArray views on an ArrayBuffer. If you don't pass in an ArrayBuffer, one will be created. If you're using an unsized array then you must pass in your own arraybuffer

    Example:

    const code = `
    struct Stuff {
    direction: vec3f,
    strength: f32,
    matrix: mat4x4f,
    };
    @group(0) @binding(0) var<uniform> uni: Stuff;
    `;
    const defs = makeShaderDataDefinitions(code);
    const views = makeTypedArrayViews(devs.uniforms.uni.typeDefinition);

    views would effectively be

    views = {
    direction: Float32Array(arrayBuffer, 0, 3),
    strength: Float32Array(arrayBuffer, 3, 4),
    matrix: Float32Array(arraybuffer, 4, 20),
    };

    You can use the views directly or you can use

    Parameters

    • typeDef: TypeDefinition

      Definition of the various types of views.

    • Optional arrayBuffer: ArrayBuffer

      Optional ArrayBuffer to use (if one provided one will be created)

    • Optional offset: number

      Optional offset in existing ArrayBuffer to start the views.

    Returns ArrayBufferViews

    A bunch of named TypedArray views and the ArrayBuffer

    Link

Generated using TypeDoc