Ship assets
without surprises.
Glint validates binary assets early, preserves useful error context, and keeps optional native texture transcoding outside the core package.
Declare model sources
const local = Model.asset('assets/models/level.glb');
final remote = Model.network(
'https://cdn.example.com/vehicle.glb',
timeout: const Duration(seconds: 12),
maximumBytes: 24 * 1024 * 1024,
);Package local models in flutter.assets. Network sources enforce time and byte limits so a stalled or oversized response becomes an actionable error instead of an unbounded allocation.
Know the glTF coverage
Geometry
GLB containers, scene roots, node hierarchy, triangle primitives, 16/32-bit indices, authored or generated normals.
Materials
Per-primitive base-color textures and factors, metallic, roughness, and embedded images.
Animation
Node TRS clips, skeletal skins, float or normalized integer weights, and LINEAR/STEP/CUBICSPLINE sampling.
Basis extension
KHR_texture_basisu selects a KTX2 source ahead of its optional PNG/JPEG fallback.
Draco geometry compression and authored normal/ORM texture maps are not imported in 0.2. Keep a non-Draco GLB in the delivery pipeline.
Use one decoder boundary
GlintTextureDecoder handles raster images, core KTX2 formats, and an optional Basis transcoder. Pass the same decoder to the game view so model, particle, and graph textures follow one policy.
final decoder = GlintTextureDecoder(
basisTranscoder: const GlintBasisTranscoder(),
);
GlintGameView(
textureDecoder: decoder,
particleTextures: const {
'smoke': GlintTextureSource.asset('assets/textures/smoke.ktx2'),
},
models: models,
onFrame: buildFrame,
)Texture sources support assets, files, bounded network URLs, and application-managed encoded memory.
Add KTX2 and Basis
flutter pub add glint_basisThe core decoder reads uncompressed RGB, RGBA, and BGRA KTX2. glint_basis adds the official Basis Universal transcoder for BasisLZ, UASTC, Zstd-supercompressed KTX2, and standalone .basis data.
final pixels = await GlintTexturePixels.fromAsset(
'assets/textures/bodywork.ktx2',
decoder: decoder,
maximumDimension: 2048,
);The decoder selects a suitable mip before transcoding and performs native transcoding on a background isolate.
Separate delivery compression from GPU residency
Flutter GPU does not currently expose ASTC, ETC, BC texture formats or per-mip uploads to Dart. Glint therefore transcodes Basis data to RGBA8 before upload.
What improves nowPackage size, download size, CDN storage, source-format flexibility, and background mip selection.
What does not improve yetFinal GPU texture memory and compressed sampling bandwidth; the resident texture is RGBA8.
Future pathSelect native ASTC/ETC/BC targets when Flutter GPU exposes compressed texture allocation and mip upload.
Handle failures explicitly
Show a loading or fallback state around remote content. Glint distinguishes HTTP, timeout, size, malformed GLB, unsupported accessor, image decode, KTX2, and transcode failures so logs point to the asset and stage that failed.