Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Geometry<T>

Drawable geometry with multiple vertex attributes.

example
import { Geometry } from '@gdgt/webgl';

const geometry = new Geometry( {
attributes: {
0: {
data: new Float32Array([-1, 1, 0, -1, -1, 0, 1, -1, 0, 1, 1, 0]),
type: BufferDataType.float,
size: 3,
},
2: {
data: new Float32Array([0, 0, 0, 1, 1, 1, 1, 0]),
type: BufferDataType.float,
size: 2,
},
},
indices: {
data: new Uint16Array([0, 1, 2, 2, 3, 0]),
type: BufferDataType.unsignedShort,
},
} );

// you can now upload all geometry buffers...
await geometry.upload();

// ...and draw the geometry afterwards.
someProgram.use();
geometry.draw();

Type Parameters

Hierarchy

  • default
    • Geometry

Index

Properties

ready: Promise<void>
instanceCount: number

How many geometry instances will be drawn.

attributes: { [ key in string | number | symbol]: T["attributes"][key] extends { buffer: SyncableBuffer<ArrayBuffer> } | { data: ArrayBufferView } ? SyncableBuffer<ArrayBuffer> : Buffer }

The underlying attribute buffers.

indices: T["indices"] extends { buffer: SyncableBuffer<ArrayBuffer> } | { data: ArrayBufferView } ? SyncableBuffer<ArrayBuffer> : T["indices"] extends { buffer: Buffer } ? Buffer : undefined

The underlying index buffer.

Only present if indices were declared on initialization.

Constructors

  • new Geometry<T>(__namedParameters: T): Geometry<T>

Methods

  • setInstanceCount(count: number): void
  • Sets the amount of geometry instances to draw.

    Keep in mind that this shouldn't exceed the number of instances specified in any instanced attribute.

    Parameters

    • count: number

      The amount of geometry instances to draw.

    Returns void

Generated using TypeDoc