Model
Quick answer
Model is the high-level drawable that combines shaders, vertex attributes, a buffer layout and render state into one object. Construct new Model(device, {vs, fs, attributes, bufferLayout, topology, parameters}), then call draw(renderPass) each frame. In v9 uniforms live in uniform buffers rather than setUniforms.
new Model ( device , props ) → Model
Key points
- Constructor accepts vs, fs, modules, attributes, bufferLayout and topology.
- draw(renderPass) returns false when resources or bindings are incomplete.
- setVertexCount, setInstanceCount and setBindings update state between draws.
Example
const positions = device.createBuffer(new Float32Array([
-0.6, -0.45, 0,
0.6, -0.45, 0,
0.0, 0.55, 0
]));
const colors = device.createBuffer(new Float32Array([
0.95, 0.36, 0.32,
0.98, 0.78, 0.35,
0.35, 0.80, 0.95
]));
const model = new Model(device, {
topology: 'triangle-list',
vertexCount: 3,
attributes: {
positions: positions,
colors: colors
},
bufferLayout: [
{ name: 'positions', stepMode: 'vertex', format: 'float32x3' },
{ name: 'colors', stepMode: 'vertex', format: 'float32x3' }
],
vs: '#version 300 es\n...',
fs: '#version 300 es\n...'
});const pass = device.beginRenderPass({ clearColor: [0.04, 0.06, 0.09, 1] });
model.setVertexCount(count);
model.draw(pass);
pass.end();
Notes
- There is no setUniforms in v9; per-frame values belong in uniform buffers.
- A bufferLayout that disagrees with the shader layout silently drops attributes.
English edition written for Atlaslog. Code is taken from the original Chinese page and runs unchanged.
Atlaslog (2026). Model. https://www.jingweizhi.com/en/lumagl/api/model.html (accessed 2026-11-03).