assets library
Model loading for just_graphics_engine: glTF 2.0 (.gltf and .glb)
into ModelData, ready to upload, with its animation clips; import
settings and cooked .jmodel copies; environment maps from a gradient
sky or a Radiance .hdr; meshes built in code (MeshBuilder). Pure
data, no GPU; heavy work runs in a background isolate.
Classes
- AnimationChannelData
- One animated property of one node.
- AnimationClip
- A glTF animation, ready to sample: sample writes the nodes it moves at any time into a Pose.
- AnimationData
- A glTF animation (a clip).
- AnimationSamplerData
- Keyframes: times and values.
- CookedModel
-
The cooked model format (
.jmodel): a ModelData ready to upload — vertices and indices as the renderer takes them, textures decoded with their mip levels — so loading it parses no glTF and decodes no image. - CookedResult
- What cookModel made.
- EnvironmentMapData
- What lights a scene from all round, ready for the GPU: a small cube map of what surrounds it — level 0 the sky itself, each smaller level blurred for a rougher surface (GGX, prefiltered here on the CPU) — and its diffuse light as nine spherical-harmonic coefficients.
- HdrImage
-
An image of linear RGB floats: a Radiance
.hdrdecoded. - ImageData
- An image as stored in the file (PNG, JPEG, …).
- LightData
-
KHR_lights_punctual: a light pointing down its node's -Z. - MaterialData
-
A glTF metallic-roughness material, with the extensions this renderer
reads (
KHR_materials_unlit,KHR_materials_emissive_strength,KHR_texture_transform). - MaterialOverride
- Changes to one material; a null field keeps the file's value.
- MeshBuilder
- Builds a ShapeMesh a vertex and a triangle at a time. Each triangle is wound to face the way its vertices' normals point, whichever order it was given in.
- MeshData
- One glTF mesh.
- ModelData
- A model, ready for the GPU: meshes as interleaved vertices and indices, materials, encoded images, the node tree and its lights. In the file's own axes (glTF: +Y up); the renderer corrects axes once, at the root.
- ModelImportSettings
-
How a model file is imported: what an editor saves beside it as
<model>.import.json(see ModelImportSettings.sidecarOf) and what cooking it (cookModel) applies. - NodeData
- A node of the model's tree.
- Pose
- Every node's translation, rotation and scale: what an animation moves.
- PrimitiveData
- Triangles with one material.
- RgbaImage
- An image as RGBA8 pixels.
- SamplerData
- glTF sampler state (GL enum values).
- ShapeMesh
- A 3-D shape's triangles on the CPU, in its own space: the renderer's axes (+Y down), metres. Front faces wind counter-clockwise seen from outside, as glTF's do once turned into engine axes.
- ShapeUv
- How a shape lays its texture out.
- SkinData
- A glTF skin: the nodes that are its joints and how the mesh sat on them.
- TextureData
- A texture: an image and how to sample it.
- TextureRef
- A material's use of a texture.
- VertexOffsets
- Byte offsets of each attribute inside one vertex.
Enums
- AlphaMode
- How a material treats alpha.
- AnimationInterpolation
- How values between keys are found.
- AnimationPath
- What an animation channel moves.
- LightType
- A punctual light.
- TextureCompression
- How cooked textures are stored.
Constants
- kSkinFloats → const int
- Floats per vertex in PrimitiveData.skin: four joint indices (as floats) and their four weights, which sum to 1.
- kVertexFloats → const int
- Floats per vertex in PrimitiveData.vertices: position (3), normal (3), tangent (4, w = handedness; all zero when the file had none), uv (2), colour (4).
-
supportedGltfExtensions
→ const Set<
String> - Extensions this loader reads. A file that requires any other is refused, since it can't be shown correctly without it.
Functions
-
buildMips(
RgbaImage image, {required bool srgb, int? maxLevels}) → Future< List< RgbaImage> > -
Builds the mip chain of
imagein a background isolate, at mostmaxLevelslevels (all the way to 1×1 by default): level 0 is the image itself.srgbaverages in linear light, so colour textures do not darken as they shrink. -
cookModel(
Uint8List source, {required String name, ModelFetch? fetch, ModelImportSettings settings = const ModelImportSettings()}) → Future< CookedResult> -
Cooks the model file
source(.glbor.gltf, namedname;fetchreads files a.gltfrefers to) withsettings: lengths scaled, materials changed, every texture decoded, shrunk to ModelImportSettings.maxTextureSize and given its mip levels (sRGB averaged for colour maps, linear for data maps). The result loads with no glTF parsing and no image decoding. -
cookStamp(
Uint8List source, ModelImportSettings settings) → String -
A short fingerprint of
sourceandsettings: a cooked model made from both carries it (CookedModel.stampOf), so a tool can tell when it needs cooking again. -
decodeImage(
Uint8List encoded) → Future< RgbaImage> - Decodes a PNG or JPEG (anything Flutter decodes) into RGBA8. Must run on the root isolate; Flutter decodes off the UI thread itself.
-
decodeRadianceHdr(
Uint8List bytes) → HdrImage -
Decodes a Radiance
.hdr(RGBE, flat or run-length encoded,-Y w +X horientation) into linear RGB floats. -
halve(
RgbaImage image, {required bool srgb}) → RgbaImage -
imageat half size (each side halved, at least 1), every pixel the average of up to four source pixels. Alpha is always averaged linearly. -
loadModelData(
Uint8List bytes, {required String name, ModelFetch? fetch}) → Future< ModelData> -
Reads a glTF model —
.glbor.gltf— into ModelData.
Typedefs
-
ModelFetch
= Future<
Uint8List> Function(String uri) - Fetches a file a glTF refers to, by the URI the file used (relative to the model).