builtInModelDecoder function
The decoder this package ships for format, configured from request.
The built-in readers are ModelDecoders too, and this is the one place
they are made: decodeModelBytes reaches them here after an application's
own decoders have passed, and anything else that wants "what this package
would read this with" — a converter, a drop target — asks the same
function rather than keeping a switch of its own that could fall behind.
An application that wants a built-in reader configured differently puts
one in ModelLoadRequest.decoders, where it is asked first.
Implementation
ModelDecoder builtInModelDecoder(
ModelFormat format,
ModelLoadRequest request,
) => switch (format) {
// Synchronous and essentially free: the header is read and everything
// else becomes a view over these bytes when it is asked for.
ModelFormat.f3d => const F3dDecoder(),
ModelFormat.obj => ObjLoader(
layout: request.layout,
normals: request.objNormals,
),
ModelFormat.stl => StlLoader(
layout: request.layout,
normals: request.stlNormals,
),
ModelFormat.gltf || ModelFormat.auto => GltfLoader(layout: request.layout),
};