Geometry
Geometry is the CPU-side geometry container used by engine classes.
It stores typed-array attributes and optional indices and computes vertexCount automatically when not supplied.
Usage
import {Geometry} from '@luma.gl/engine';
const geometry = new Geometry({
topology: 'triangle-list',
attributes: {
POSITION: {size: 3, value: new Float32Array([0, 0, 0, 1, 0, 0, 0, 1, 0])}
}
});
Types
GeometryProps
export type GeometryProps = {
id?: string;
topology: 'point-list' | 'line-list' | 'line-strip' | 'triangle-list' | 'triangle-strip';
vertexCount?: number;
attributes: Record<string, GeometryAttribute | TypedArray>;
indices?: GeometryAttribute | TypedArray;
};
GeometryAttribute
export type GeometryAttribute = {
size?: number;
value: TypedArray;
[key: string]: any;
};
Properties
id
Application-provided identifier.
topology
Primitive topology used by consumers of the geometry.
vertexCount
Explicit or auto-calculated vertex count.
indices
Optional index attribute.
attributes
Named geometry attributes such as POSITION, NORMAL, TEXCOORD_0, or application-defined attributes.
userData
Application-owned metadata.
Methods
constructor(props: GeometryProps)
Creates a geometry object and normalizes raw typed arrays into GeometryAttribute records.
getVertexCount(): number
Returns the resolved vertex count.
getAttributes(): GeometryAttributes
Returns the geometry attributes, including indices when present.
Remarks
POSITIONorpositionsdefaults tosize: 3when the size is omitted.- Use
GPUGeometrywhen geometry data is already uploaded into GPU buffers.