Geometry
Quick answer
In v9 Geometry is a CPU-only container: it stores typed attribute arrays, optional indices, topology and a derived buffer layout, and owns no GPU buffers. Construct it with new Geometry and hand it to a Model, which uploads the data. GPUGeometry represents buffers already resident on the device.
new Geometry ( props ) → Geometry
Key points
- Props include topology, attributes, indices, vertexCount and bufferLayout.
- getAttributes() returns every CPU attribute, including the index buffer.
- Model accepts a CPU Geometry and creates the matching buffers.
Example
const geometry = new Geometry({
topology: 'triangle-list',
attributes: {
positions: new Float32Array([
-0.6, -0.45, 0,
0.6, -0.45, 0,
0.0, 0.55, 0
]),
colors: new Float32Array([
0.95, 0.36, 0.32,
0.98, 0.78, 0.35,
0.35, 0.80, 0.95
])
},
indices: new Uint16Array([0, 1, 2])
});
console.log(geometry.getVertexCount()); // 3const model = new Model(device, {
geometry: geometry,
vs: vsSource,
fs: fsSource
});
const pass = device.beginRenderPass({ clearColor: [0.04, 0.06, 0.09, 1] });
model.draw(pass);
pass.end();
Notes
- Mutating attribute arrays after upload does not update the GPU copy.
- Vertex counts inferred from mismatched attribute lengths corrupt draws.
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Atlaslog (2026). Geometry. https://www.jingweizhi.com/en/lumagl/api/geometry.html (accessed 2026-11-03).