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, …).
- Light3DData
-
KHR_lights_punctual: a light pointing down its node's -Z. - Material3DData
-
A glTF metallic-roughness material, with the extensions this renderer
reads (
KHR_materials_unlit,KHR_materials_emissive_strength,KHR_texture_transform). - Material3DOverride
- Changes to one material; a null field keeps the file's value.
- MeshBuilder
- Builds a Shape3DMesh 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).
- Shape3DMesh
- 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.
- Shape3DUv
- 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.
- Light3DKind
-
The kind of a 3-D light: what a model's light (Light3DData) is, what
the renderer draws (
Punctual3DLight), and what just_game_engine'sLight3DComponentsaves (by value name). - TextureCompression
- How cooked textures are stored.
- UvMode
- Where a material's textures are read.
Constants
- cookerVersion → const int
- The version of what cookModel makes. Bumped with every change to cooking (how textures are decoded, what the cooked file holds), so a model cooked before has another cookStamp and is cooked again.
- 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, int maxSize = 0}) → 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, first halved until neither side is overmaxSize(0: no limit).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, and is stamped (cookStamp) with every file it was made from. -
cookStamp(
Uint8List source, ModelImportSettings settings, {Map< String, Uint8List> files = const {}}) → String -
A short fingerprint of what a cooked model is made from: the model file
source, every file it refers to (files: a.gltf's buffers and images, by the paths modelFilesOf lists), itssettingsand the cookerVersion. A cooked model carries it (CookedModel.stampOf), so a tool can tell when it needs cooking again: a texture repainted, a buffer exported again or the cooker changed, as well as the file or its settings. The same on every platform, the web included. -
decodeImage(
Uint8List encoded) → Future< RgbaImage> - Decodes a PNG or JPEG (anything Flutter decodes) into RGBA8 with straight (not premultiplied) alpha, as glTF textures are authored and the renderer blends them. 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. Throws a FormatException for a malformed or cut-short file. -
loadModelData(
Uint8List bytes, {required String name, ModelFetch? fetch}) → Future< ModelData> -
Reads a glTF model —
.glbor.gltf— into ModelData. -
modelClipNamesOf(
Uint8List bytes) → List< String> -
The names of the clips the model file
bytes(.glbor.gltf) has, in its order, as loadModelData names them: an animation's own name, oranimation <index>for one with none; an animation that moves nothing the loader animates makes no clip. A.glb's bytes may end after its JSON chunk: only the JSON is read. -
modelFilesOf(
Uint8List bytes) → List< String> -
The files the model file
bytes(.glbor.gltf) refers to: a.gltf's buffers and images, a.glb's external images. Each once, in the order the file names them, as the paths loadModelData asks its fetch for (relative to the model, URI-decoded). Empty for a self-contained file.
Typedefs
-
ModelFetch
= Future<
Uint8List> Function(String path) - Fetches a file a glTF refers to, by its path relative to the model (the URI the model used, decoded).