flutter3d_app library

What any Flutter application on flutter3d is assembled from, in one import.

import 'package:flutter3d_app/flutter3d_app.dart';

final device = await openDevice(width: 1280, height: 720);
final renderer = Renderer.create(device: device);
// ... SceneSurface, presentFrame, LevelLoader, WidgetSurface, Storage

Universal, and that is the test for a place here. The modeller, the level editor, the lessons and every game use what is below, and nothing here knows what a run, a binding or a monster is. What a game adds on top — the devices it is played with, the run, its settings screens, the actors and fixtures its simulation moves — is flutter3d_game, which stands on this package.

  • The backend choice. openDevice and presentFrame look a backend up in flutter3d_hardware's own device registry, with the runtime fallback to software when Impeller will not start. Each backend registers itself, so a new one costs this file nothing.
  • The surface. SceneSurface hands a rendered frame to Flutter; its settings are a function called per frame, so anything derived from where the camera ended up is derived after it got there. FrameClock, FrameTimingLog, DidNotStart and the status screens are pacing, the numbers a frame panel shows, and what an application says when it cannot draw or cannot read its level.
  • Widgets in the scene. WidgetSurface draws a Flutter widget onto a quad the scene holds, and WidgetSurfaceVisuals builds one for each widget_surface a level names.
  • A level loaded into a scene. LevelLoader turns a level document into mesh nodes, lights, probes and a collision world, with SharedMeshes and VisibilityCuller beside it. An editor draws the level it is editing with the same code a game plays it with.
  • Storage, and what a document says when it cannot be read. Storage and BinaryStorage keep a document where each platform keeps such things, and an Issue is handed back rather than thrown.

package:flutter3d_app/native.dart holds the one piece that needs a filesystem, off this barrel so a dart:io import never stops a web build compiling.

Classes

BinaryStorage
Where a document too large or too binary for Storage lives.
DidNotStart
The screen an application shows when it could not open a renderer.
FileBinaryStorage
Documents kept as files, the binary half of FileStorage.
FileStorage
Documents kept as files, one per name, in a directory this platform owns.
FrameClock
How long since the last frame, measured on the wall clock.
FrameTimingLog
Prints what a frame costs, when the command line asks for it.
Issue
What a library is reporting.
IssueLog
Collects issues instead of printing them.
LevelBatching
How a level's brushes are grouped into draws.
LevelLoader
Reads a level asset and turns it into something playable.
LevelLoadFailed
Shown when asset threw rather than loaded.
LoadedLevel
A loaded level, in the two forms the game needs it.
LoadingScreen
Shown between a renderer that has started and a level that has not yet.
MemoryPressureRelease
Wraps child and gives renderer's pooled targets back when the platform warns about memory.
ModelVisuals
edu-07b: the path edu-07a's own doc comment names as the one prop does not close — a real glTF/.f3d asset, loaded the way every other modelled thing in this repo already loads one (decodeModelInIsolate + ModelAsset.fromDocument, fixture_visuals.dart's own _load), rather than a box or a cylinder standing in for it.
PropVisuals
edu-07's answer to the gap doc/tooling-plan.md names: neither a brush (batched by material, configurator.json's own doc comment already says there is "no way to address this one box in scene.meshes") nor a type: "model" entity (a decoded asset, loaded by ModelVisuals rather than by LevelLoader) gives a level document one named, individually addressable piece of procedural geometry. A prop entity does: one primitive shape, one MeshNode of its own, not merged into any batch — so it can be found by EntityDef.name the same way a widget_surface's own node already can, and applyLessonStepToCamera's nodes/restPositions can reach it.
RendererFailure
Shown before the renderer exists, and if it never does.
SceneAnnouncement
One object as the application knows it, before anything is projected.
SceneSemantics
Publishes objects to the platform's accessibility layer on top of child.
SceneSurface
The widget that hands a rendered frame to Flutter.
SemanticObject
One object, as the accessibility layer will meet it.
SharedMeshes
One uploaded mesh per distinct shape, shared by everything that asks for it.
Storage
Where a game keeps the small documents a player's choices live in.
TerrainTiles
Every tile of tiles as a node, and the levels they draw at.
VisibilityCuller
Hides the level's batches a camera cannot see, once a frame.
WidgetSurface
wg-01: a live Flutter widget as a mesh in the 3D scene, the node WidgetSurfacePipeline's own docstring names as not yet built.
WidgetSurfaceKind
The kind a genre's own EntityRegistry registers for widget_surface — found the hard way, not designed ahead of time: LevelValidator treats an entity type its registry does not know as an ERROR that fails the whole document (LevelLoader.load throws), which is a stricter door than flutter3d_editor_core's OpenKind — the editor's open vocabulary validates a level flutter3d_sim's own loader would refuse. wg-02 hit this loading a real level with a widget_surface entity and no kind for it registered; wg-01's own write-up did not, because nothing in it loaded a level through a genre's closed registry.
WidgetSurfacePipeline
A widget's own render pipeline, kept alive across draws and pointer events.
WidgetSurfaceVisuals
wg-01: a widget_surface entity in a level document, resolved into a live WidgetSurface the same way a fixture resolves into a mesh (fixture_visuals.dart) — the simulation names an entity by its flat property bag, and this is the one place that turns it into a node.
WidgetTexture
Draws widgets into textures on one device.

Constants

kFixedResolution → const bool
Whether this build renders at a fixed internal resolution.

Functions

applicationDirectory({required String appName, required TargetPlatform platform, required Map<String, String> environment, required String temporary}) → String?
Where this platform keeps a small document belonging to one application.
applicationFolder(String appName) → String?
Where appName keeps its documents on this platform, as a path — for an application offering to show somebody the folder a write failed in.
defaultBinaryStorage(String appName, {IssueSink? onIssue}) → BinaryStorage
The binary storage a build outside the browser gets.
defaultStorage(String appName, {IssueSink? onIssue}) → Storage
The storage a build outside the browser gets.
meshDataOf(BrushSurface surface) → MeshData
Interleaves the level package's plain arrays into the engine's layout.
openDevice({required int width, required int height}) → Future<GraphicsDevice>
Opens the backend, or throws with something worth putting on screen.
presentFrame(GraphicsDevice device, TextureHandle frame, {BoxFit fit = BoxFit.fill, FilterQuality quality = FilterQuality.none}) → Widget
The widget that shows frame, for whichever device this build's openDevice actually returned — or for any other GraphicsDevice a caller registered with registerDevicePresenter, native backend or not.
printIssue(Issue issue) → void
Prints and carries on: the behaviour every one of these sites had.
resolveApplicationDirectory({required String appName, required IssueSink onIssue}) → Directory?
applicationDirectory resolved for the current platform, or null with onIssue told why — the shared half of FileStorage and FileBinaryStorage, which otherwise differ only in what they do with the directory once they have it.
semanticObjectsFor(List<SceneAnnouncement> announcements, {required CameraNode camera, required Size size}) → List<SemanticObject>
announcements projected through camera for a viewport of size.
unmountWidgetTree(BuildOwner build, RenderObjectToWidgetElement<RenderBox> element, RenderObjectWithChildMixin<RenderBox> container) → void
Drops everything element built into container, and unmounts it.

Typedefs

AssetBytes = Future<ByteData> Function(AssetRequest request)
How a level's own files are found.
DocumentText = Future<String> Function(AssetRequest request)
How a level's own document is found.
FramePresenter = Widget Function(GraphicsDevice device, TextureHandle frame, {BoxFit fit, FilterQuality quality})
The shape of presentFrame, and of every presenter a backend registers.
IssueSink = void Function(Issue issue)
VisibilityBatch = ({Aabb3 bounds, MeshNode node})
One batch of level geometry and the box it fills.