Skip to content

geometry#positions

Summary

geometry#positions exposes the CPU-side packed XYZ records when retained. The adjacent vertex attributes and index array can be used to inspect the same mesh before upload or to build another geometry from its retained data.

Syntax

Geometry.positions: Float32Array
Geometry.normals: Float32Array
Geometry.tangents: Float32Array
Geometry.colors: Float32Array
Geometry.uvs: Float32Array
Geometry.uvs1: Float32Array
Geometry.indices: Uint32Array | null
Geometry.vertexCount: number
Geometry.indexCount: number
const positions = geometry.positions;

Notes

Each vertex has three position floats, three normal floats, four tangent floats, four color floats and two floats per UV set. Index data uses zero-based u32 vertex indices. The first and second UV sets are separate arrays. CPU-backed channels remain available after upload. For a borrowed Wasm channel, use keepCPUData: true to capture a CPU snapshot when refreshing. vertexCount and indexCount describe the active records even when Wasm-backed data has no CPU snapshot.

Example

const geometry = wgpu.geometry.box(1, 1, 1);
const firstVertex = geometry.positions.slice(0, 3);
geometry.destroy();

See Also