gpu-curtains
    Preparing search index...

    Used to create a Geometry from given parameters like instances count or geometry attributes (vertices, uvs, normals).
    Holds all attributes arrays, bounding box and create as WGSL code snippet for the vertex shader input attributes.

    During the render, the Geometry is responsible for setting the vertexBuffers and drawing the vertices.

    const vertices = new Float32Array([
    // first triangle
    1, 1, 0,
    1, -1, 0,
    -1, -1, 0,

    // second triangle
    1, 1, 0,
    -1, -1, 0,
    -1, 1, 0
    ])

    // create a quad geometry made of 2 triangles
    const geometry = new Geometry()

    geometry.setAttribute({
    name: 'position',
    type: 'vec3f',
    bufferFormat: 'float32x3',
    size: 3,
    bufferLength: vertices.length,
    array: vertices,
    })

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    verticesCount: number

    Number of vertices defined by this geometry.

    verticesOrder: GPUFrontFace

    Vertices order to be drawn by the render pipeline.

    topology: GPUPrimitiveTopology

    Topology to use with this Geometry, i.e. whether to draw triangles or points.

    instancesCount: number

    Number of instances of this geometry to draw.

    vertexBuffers: VertexBuffer[]

    Array of vertex buffers to use with this geometry.

    Options used to create this geometry.

    type: string

    The type of the geometry.

    uuid: string

    The universal unique id of the geometry.

    indirectDraw: IndirectDrawParams

    Allow to draw this Geometry with an IndirectBuffer if set.

    boundingBox: Box3

    The bounding box of the geometry, i.e. two Vec3 defining the min and max positions to wrap this geometry in a cube.

    wgslStructFragment: string

    A string to append to our shaders code describing the WGSL structure representing this geometry attributes.

    layoutCacheKey: string

    A string representing the vertexBuffers layout, used for pipelines caching.

    consumers: Set<string>

    A Set to store this Geometry consumers (Mesh uuid).

    ready: boolean

    Whether this geometry is ready to be drawn, i.e. it has been computed and all its vertex buffers have been created.

    Accessors

    • get shouldCompute(): boolean

      Get whether this Geometry is ready to compute, i.e. if its first vertex buffer array has not been created yet.

      Returns boolean

    Methods

    • Compute the normal Vec3 from a triangle defined by three Vec3 by computing edges Vec3.

      Parameters

      • vertex1: Vec3

        First triangle position.

      • vertex2: Vec3

        Second triangle position.

      • vertex3: Vec3

        Third triangle position.

      • edge1: Vec3

        First edge.

      • edge2: Vec3

        Second edge.

      • normal: Vec3

        Flat normal generated.

      Returns void

    • Compute a Geometry, which means iterate through all vertex buffers and create the attributes array that will be sent as buffers. Also compute the Geometry bounding box.

      Returns void