GPUGeometry
GPUGeometry is the GPU-backed counterpart to Geometry.
It stores already-created luma.gl Buffer objects plus the corresponding bufferLayout metadata.
Use it when geometry data is already on the GPU and should not be re-uploaded from typed arrays.
When CPU Geometry is converted through makeGPUGeometry(), it is first interleaved so the upload uses
one vertex buffer plus an optional index buffer.
Usage
import {GPUGeometry} from '@luma.gl/engine';
const gpuGeometry = new GPUGeometry({
topology: 'triangle-list',
vertexCount: 3,
bufferLayout: [{name: 'positions', format: 'float32x3'}],
attributes: {
positions: positionBuffer
}
});
Types
GPUGeometryProps
export type GPUGeometryProps = {
id?: string;
topology: 'point-list' | 'line-list' | 'line-strip' | 'triangle-list' | 'triangle-strip';
vertexCount: number;
bufferLayout: BufferLayout[];
indices?: Buffer | null;
attributes: Record<string, Buffer>;
};
Properties
id, topology, vertexCount
Basic geometry identity and draw metadata.
bufferLayout
The GPU buffer layout that matches the provided attributes.
indices
Optional index buffer.
attributes
Named vertex buffers. Keys match bufferLayout[].name.
userData
Application-owned metadata.
Methods
constructor(props: GPUGeometryProps)
Creates a GPU-backed geometry object. Validates that indices, when present, has Buffer.INDEX usage.
destroy(): void
Destroys the index buffer and all attribute buffers managed by this object.
getVertexCount(): number
Returns the vertex count.
getAttributes(): Record<string, Buffer>
Returns the attribute buffers.
getIndexes(): Buffer | null
Returns the index buffer when present.
Related Helpers
makeGPUGeometry(device, geometry)converts a CPUGeometryintoGPUGeometry. CPU input is interleaved before upload;GPUGeometryinput is returned unchanged.getIndexBufferFromGeometry(device, geometry)extracts or creates an index buffer.getAttributeBuffersFromGeometry(device, geometry)creates one GPU vertex buffer per CPU geometry attribute key and preserves the geometry'sbufferLayout.