Model loading · interface
ImageInfo
What an image is, from its own first bytes. One responsibility: identify, never decode.
Explained in Importing models.
interface ImageInfoimport type { ImageInfo } from '@driftengine/assets';In depth
The baker embeds compressed images untouched, so it never decodes one — but the format stores a codec and a size beside each payload, and both have to come from somewhere. They come from here, by reading the few bytes every container puts at its front for exactly this purpose.
Why the size is stored at all, when the decoder will report it anyway. A loader that has to decode before it can size anything cannot budget: it learns that a level carries 400 MB of texture only after it has allocated it. Reading it here costs a dozen bytes per texture and lets a consumer refuse, downscale or stream before committing.
The extension is not consulted. A .jpg that is really a PNG is common enough to be
unremarkable, and every one of these formats identifies itself unambiguously in its first
bytes. Trusting the name over the content is how a file that would have loaded fine gets
refused, and how one that cannot be decoded gets embedded anyway.
Properties
| Name | Type | Description |
|---|---|---|
codecreadonly | number | |
widthreadonly | number | |
heightreadonly | number |