The .drft container · function
validateMeshData
Every attribute covers every vertex, and every index names one that exists.
Explained in The .drft container.
function validateMeshData(data: MeshData): voidimport { validateMeshData } from '@driftengine/drft';Parameters
| Parameter | Type | Description |
|---|---|---|
data | MeshData |
In depth
Why this is checked rather than assumed. WebGL does not require a driver to survive an attribute buffer that is too small for the draw: the implementation may read zeroes, and it may equally drop the draw entirely. Desktop drivers clamp and carry on, which means a mesh with one short array renders perfectly for the author and vanishes without a word on hardware they do not own. There is no GL error either way, so nothing downstream can tell the difference between a mesh that was rejected and a mesh that was never submitted.
Thrown rather than warned, because this is construction and not a frame: a mesh built from inconsistent arrays is a bug in the caller with exactly one correct outcome, and the engine's rule is that initialisation fails loudly so a running frame never has to.
The message names the array, its length, and the length it should have had — everything needed to fix it without a debugger, since the machine where this fires may not have one.