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.
openDeviceandpresentFramelook a backend up influtter3d_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_surfacea 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 pathedu-07a's own doc comment names as the onepropdoes not close — a real glTF/.f3dasset, 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 gapdoc/tooling-plan.mdnames: neither a brush (batched by material,configurator.json's own doc comment already says there is "no way to address this one box inscene.meshes") nor atype: "model"entity (a decoded asset, loaded byModelVisualsrather than by LevelLoader) gives a level document one named, individually addressable piece of procedural geometry. Apropentity does: one primitive shape, oneMeshNodeof its own, not merged into any batch — so it can be found byEntityDef.namethe same way awidget_surface's own node already can, andapplyLessonStepToCamera'snodes/restPositionscan 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.
- 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 nodeWidgetSurfacePipeline's own docstring names as not yet built. - WidgetSurfaceKind
-
The kind a genre's own
EntityRegistryregisters forwidget_surface— found the hard way, not designed ahead of time:LevelValidatortreats an entity type its registry does not know as an ERROR that fails the whole document (LevelLoader.loadthrows), which is a stricter door thanflutter3d_editor_core'sOpenKind— the editor's open vocabulary validates a levelflutter3d_sim's own loader would refuse.wg-02hit this loading a real level with awidget_surfaceentity 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: awidget_surfaceentity 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
appNamekeeps 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 whicheverdevicethis build's openDevice actually returned — or for any otherGraphicsDevicea caller registered withregisterDevicePresenter, 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
onIssuetold 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> -
announcementsprojected throughcamerafor a viewport ofsize. -
unmountWidgetTree(
BuildOwner build, RenderObjectToWidgetElement< RenderBox> element, RenderObjectWithChildMixin<RenderBox> container) → void -
Drops everything
elementbuilt intocontainer, 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.