flutter_scene README

The project's README from github.com/bdero/flutter_scene. As one markdown file: README.md.

Flutter Scene

Flutter Scene

A complete 3D game engine for Flutter, built on Flutter GPU

Rendering, physics, audio, animation, a scene editor with an MCP server, and a full asset pipeline, on every platform Flutter runs on, web included. Built and maintained by the author of Flutter GPU.

Covered by Argos Visual Testing

Website · Docs · Examples App · Games · FAQ

Physically based rendering of the glTF DamagedHelmet sample with image-based lighting in Flutter Scene

Dashsurfers, an endless runner game built with Flutter Scene

The Flutter Scene Editor, driven by a coding agent over MCP

At a glance

Built with Scene

Why Scene exists

Scene began its life inside the Flutter Engine, as a C++ module for Impeller with a declarative widget interface exposed through a 3D API in the Flutter SDK. Flutter GPU was built initially to set this project free, providing the low-level GPU access needed to develop Scene outside the engine, as an ordinary ecosystem of Dart packages.

That origin shapes the project's philosophy. Scene is a full 3D game engine and toolkit that makes Flutter GPU practical to build on, spanning rendering, physics, audio, editor tooling, and asset support across every target Flutter runs on. And the relationship flows both ways by design. Scene's cross-backend render tests are where Flutter GPU regressions get caught, so Impeller and Flutter GPU get better because Scene exists.

The goal has always been to pave the way for advanced graphics in Flutter. In line with the goals set out in Flutter GPU's original design doc, Scene aims to de-fracture, unite, and elevate Flutter's graphics ecosystem, so that building incredible 3D experiences with Flutter and Dart no longer requires engine forks, complicated external renderer integrations, or giving up platforms to get advanced features.

Scene is built by the author of Flutter GPU, a former core Flutter engine team member who spent four years on Flutter, most of it building Impeller.

Getting started

flutter pub add flutter_scene
dart run flutter_scene:init

init sets up the asset pipeline, which is the recommended way to use Scene. Drop sources under assets/, load them by their source path, and render:

final level = await loadScene('assets/level.glb');
scene.add(level);
// ...
SceneView(scene, cameraBuilder: (elapsed) => PerspectiveCamera(...));

The same code runs on web, and the engine's shaders are compiled for you during the build by flutter_scene's own build hook. Rendering goes through Flutter GPU, which is off by default, so enable it once per platform (below). The web needs nothing.

Impeller, which Flutter GPU builds on, is the default renderer on every native platform as of 3.47, so there is nothing to do for it.

Coding agents

This package ships a set of agent skills so a coding assistant writes idiomatic Scene instead of guessing: correct usage and traps, the run-settle-capture verification loop, copy-paste look presets, procedural content, and performance. dart run flutter_scene:init offers to install them, and dart run flutter_scene:skills installs, updates, or checks them on their own without touching your build hook. Upgrading Scene can carry newer revisions; dart run flutter_scene:skills --check reports whether any are available.

Enable Flutter GPU

While developing, pass the flags on the command line:

flutter run --enable-flutter-gpu

To turn it on permanently, for every run and for the app you ship, edit the platform file:

Platform File Add
iOS ios/Runner/Info.plist <key>FLTEnableFlutterGPU</key><true/>
Android android/app/src/main/AndroidManifest.xml, in <application> <meta-data android:name="io.flutter.embedding.android.EnableFlutterGPU" android:value="true" />
macOS macos/Runner/Info.plist <key>FLTEnableFlutterGPU</key><true/>
Web nothing

Windows and Linux set it on the DartProject their runner builds. This needs Flutter 3.47.1.

// linux/runner/my_application.cc
g_autoptr(FlDartProject) project = fl_dart_project_new();
fl_dart_project_set_enable_flutter_gpu(project, TRUE);
// windows/runner/main.cpp
flutter::DartProject project(L"data");
project.set_enable_flutter_gpu(true);

On 3.47.0 there is no such setting, so desktop takes the command-line flags per run, and release builds compile the engine's environment switches out, meaning a shipped Windows or Linux release needs 3.47.1.

A scene with no assets

The built-in geometry needs no asset pipeline, so a cube renders straight after flutter pub add flutter_scene:

import 'package:flutter/material.dart';
import 'package:flutter_scene/scene.dart';
import 'package:vector_math/vector_math.dart' as vm;

void main() => runApp(const MaterialApp(home: CubeView()));

class CubeView extends StatefulWidget {
  const CubeView({super.key});

  @override
  State<CubeView> createState() => _CubeViewState();
}

class _CubeViewState extends State<CubeView> {
  final Scene scene = Scene();
  bool ready = false;

  @override
  void initState() {
    super.initState();
    // Geometry and materials touch the shader bundle, so build them once the
    // engine's static resources are up.
    Scene.initializeStaticResources().then((_) {
      scene.add(
        Node(
          mesh: Mesh(
            CuboidGeometry(vm.Vector3(1, 1, 1)),
            PhysicallyBasedMaterial(),
          ),
        ),
      );
      if (mounted) setState(() => ready = true);
    });
  }

  @override
  Widget build(BuildContext context) {
    if (!ready) return const SizedBox.expand();
    return SceneView(
      scene,
      camera: PerspectiveCamera(position: vm.Vector3(2, 2, -4)),
    );
  }
}

The scene's default studio environment lights it, so there is nothing else to set up.

Moving a node

Every Node carries a transform relative to its parent. Read and write it one component at a time, or as a whole matrix through node.localTransform.

node.position = vm.Vector3(0, 1, 0);
node.rotation = vm.Quaternion.axisAngle(vm.Vector3(0, 1, 0), 0.5);
node.scale = vm.Vector3.all(2);
node.position += vm.Vector3(0, 0.1, 0);

Each getter returns a copy, so node.position.y = 1 moves nothing. Assign the value back instead. Debug builds throw on an edit that cannot reach the node, whether it is to a returned copy or to localTransform in place.

Built-in geometry

Every class below builds vertex data for you and drops into a Mesh the same way CuboidGeometry does above.

The asset pipeline

init writes a hook/build.dart that converts your assets at build time, creates flutter_scene_generated/ with a .gitignore for its outputs, and adds that one directory to flutter.assets in your pubspec.yaml. It is safe to run again, and it will not overwrite a hook/build.dart you wrote yourself. It prints a block to paste into your existing build() callback instead.

The hook it writes discovers .glb and .fscene models, .fmat materials, and loose images under assets/, and converts each one:

// hook/build.dart
import 'package:flutter_scene/build_hooks.dart';
import 'package:hooks/hooks.dart';

void main(List<String> args) async {
  await build(args, (input, output) async {
    buildScenes(buildInput: input, buildOutput: output);
    await buildMaterials(buildInput: input, buildOutput: output);
  });
}

The one line it adds to your pubspec.yaml:

flutter:
  assets:
    - flutter_scene_generated/

Upgrading from an earlier version, run it again. Generated assets now go into that directory on every Flutter release, so re-running init migrates the hook it wrote and adds the pubspec entry. A hook still asking for a removed asset mode fails the build and names its replacement.

From then on, drop sources under assets/ and load them by source path:

final level = await loadScene('assets/level.glb');
final toon = await loadFmatMaterial('assets/toon.fmat');
final ground = await loadTexture('assets/ground.png');

A .glb has to be parsed and unpacked into GPU-ready form every time the app loads it. The pipeline does that work once, at build time, into the .fsceneb format the engine reads directly, so loading a model at runtime costs far less. Prefer it for anything that ships with your app. It is also how .fmat custom materials and block-compressed textures with full mip chains reach you, and editing any source reconverts just that source and hot reloads it.

Loose images cook to the engine's own .fstex by default. For a smaller download, cook color textures to standard ETC1S KTX2 instead, several times smaller at some cost in quality:

buildTextures(
  buildInput: input,
  buildOutput: output,
  textures: ['assets/ground.png', 'assets/ground_normal.png'],
  encoding: const TextureEncoding.etc1s(quality: 128),
  // Normal maps keep more detail in the default encoding.
  encodings: {'assets/ground_normal.png': TextureEncoding.universal},
);

Keep your sources in version control. The generated directory holds compiled output tied to the Flutter engine that built it, which is why the hook manages its .gitignore for you.

For a model that only exists once the app is running, because you download it or the user supplies it, import the .glb directly with Node.fromGlbAsset('assets/model.glb'). That needs no hook, and it parses the glTF on every load, so prefer the pipeline whenever the model ships with you.

Where to go next

fscene.dev carries the full documentation. Your first scene renders something on screen from here, and the guides cover each subsystem in depth with live demos, including assets and loading, materials, lighting and environment, animation, and cameras. The API reference documents every public symbol.

Requirements

Flutter Scene is pre-1.0 and evolving quickly. Minor releases can carry breaking changes, and every change is documented in the CHANGELOG.

Features

Rendering

Materials and shaders

Assets and animation

App integration

Ecosystem

A 3D platformer game running on Flutter Scene

Depth of field and bloom post-processing on a glTF model

Rigid-body physics through flutter_scene_rapier

Instanced rendering of thousands of animated meshes

A custom sky material written in GLSL through the .fmat format

Skinned, animated glTF characters cloned across a scene

3D Gaussian splatting rendered as a scene node

Dashmap, a streaming 3D world map built on Flutter Scene

FAQ

Q: What platforms does this package support?

On native platforms flutter_scene runs anywhere Impeller does. On the web it runs on a built-in WebGL2 backend.

Every native platform needs Flutter GPU turned on. Impeller, which it builds on, is already the default everywhere. Enable Flutter GPU has the file and the key for each.

On the web, no flags are needed; it works under both the CanvasKit and Skwasm renderers.

Platform Status
iOS 🟢 Supported
Android 🟢 Supported
Web 🟢 Supported
MacOS 🟢 Supported
Windows 🟢 Supported (3.47.1 to ship a release)
Linux 🟢 Supported (3.47.1 to ship a release)
Custom embedders 🟢 Supported

Q: How does web support work?

Impeller and Flutter GPU aren't available on the web, so flutter_scene ships a built-in WebGL2 backend (a drop-in for flutter_gpu) and renders through it there. It works under both the CanvasKit and Skwasm web renderers, with no extra flags or configuration.

Sponsors

Scene's development is funded by its sponsors, listed in full at fscene.dev/sponsors. Anyone can sponsor through GitHub Sponsors, from $5 a month. Company tiers are at fscene.dev/sponsors.

Silver

Primio

Infrastructure

To sponsor Scene, write to [email protected].

Repository

This repository is a pub workspace containing the engine, its companion packages, and the example apps:

Path Description
packages/flutter_scene The 3D engine, including the glTF importer, the .fscene format, and the web (WebGL2) backend. Published to pub.dev as flutter_scene.
packages/flutter_scene_rapier Rapier physics backend, shipping prebuilt native binaries and a wasm module. Published to pub.dev as flutter_scene_rapier.
packages/flutter_scene_box3d box3d physics backend. Published to pub.dev as flutter_scene_box3d.
packages/flutter_scene_soloud SoLoud audio backend. Published to pub.dev as flutter_scene_soloud.
packages/flutter_scene_fmod FMOD Studio audio backend. Published to pub.dev as flutter_scene_fmod.
packages/flutter_scene_net Multiplayer on dashwire, binding replicated state to scene nodes with interpolated transforms and in-app hosting. Published to pub.dev as flutter_scene_net.
packages/flutter_scene_input Rebindable input actions for keyboard, mouse, gamepads, and pointer lock, with contexts, rebinding, and scene drivers. Published to pub.dev as flutter_scene_input.
packages/scene The engine-agnostic .fscene document core and the physics contract the backends implement. Published to pub.dev as scene.
packages/flutter_scene_codegen Static extraction and code generation for annotated components. A development-time tool, not published.
packages/flutter_scene_editor_core, packages/flutter_scene_editor, packages/flutter_scene_mcp The Flutter Scene Editor stack (headless command core, Flutter UI, and MCP tool surface). Shipped as the desktop app under apps/, not as pub.dev libraries. In active development.
apps/flutter_scene_editor_app The standalone Flutter Scene Editor desktop app.
examples/flutter_app Runnable example app with 43 feature examples.

The remaining examples/ folders are dev-only test harnesses (the web-backend smoke test, deterministic smoke renders, and a CPU stress bench).

To run the example app from a fresh clone:

flutter pub get                                             # resolves the workspace

cd examples/flutter_app
flutter create . --platforms=macos,ios,android,linux,windows,web  # generate gitignored platform stubs
flutter run --enable-flutter-gpu                              # native; add `-d <device>` if needed
flutter run -d chrome                                         # web

Pass --dart-define=FLUTTER_SCENE_PROFILE=true to print 120-frame render graph, culling, encoding, instance packing, binding, byte, draw, and instance summaries. Multiple active RenderViews share the counters.

flutter_scene (bdero/flutter_scene)

Searching Database…

Что это?Flutter Scene — полноценный 3D-игровой движок реального времени для Flutter, охватывающий физически корректный рендеринг, физику, аудио, анимацию, редактор сцен и полный конвейер ассетов; работает на всех платформах, которые поддерживает Flutter, включая веб.
Это библиотека, которую я добавляю в существующее Flutter-приложение, или отдельный движок со своим приложением?Это Dart/Flutter-пакет, который вы добавляете в своё приложение, построенный как обычная экосистема Dart-пакетов поверх Flutter GPU, а не отдельный самостоятельный движок; правда, в комплекте есть настольный редактор сцен как сопутствующий инструмент.
Как добавить его в Flutter-проект?Выполните 'flutter pub add flutterscene', чтобы рендерить встроенную геометрию без какой-либо настройки, или 'dart run flutterscene:init', чтобы подключить конвейер ассетов на этапе сборки, который сам конвертирует модели из assets/.
Нужно ли что-то включить, прежде чем заработает рендеринг?Да, на всех нативных платформах, кроме веба, нужно один раз включить Flutter GPU, отредактировав файл платформы (Info.plist, AndroidManifest.xml или настольный DartProject), а также нужен Flutter 3.47 или новее (3.47.1 для готовых релизов Windows/Linux).
Достаточно ли стабилен API, чтобы строить на нём прямо сейчас?Не полностью — Flutter Scene ещё до 1.0 и быстро развивается, минорные релизы могут ломать совместимость, хотя каждое такое изменение задокументировано в CHANGELOG.
На каких платформах он реально работает?iOS, Android, macOS, Windows, Linux и веб — нативные платформы рендерят через Impeller/Flutter GPU, а веб использует вместо этого встроенный бэкенд WebGL2.
Что делает интеграция MCP-сервера и агентных навыков?Настольный редактор сцен открывает MCP-сервер для редактирования силами агентов, а пакет может установить агентные навыки (через flutterscene:init или flutterscene:skills), чтобы кодинг-ассистенты писали корректный код Scene, включая цикл проверки run-settle-capture и пресеты производительности.
Какие форматы ассетов можно импортировать?Он импортирует glTF (.glb/.gltf), собственный формат сцен .fscene, кастомные GLSL-материалы .fmat, сжатые текстуры KTX2 и окружения HDR/EXR, конвертируя их на этапе сборки в быстро загружаемые форматы .fsceneb и .fstex.
Почему автор построил отдельный движок, а не расширил движок Flutter?Scene создал бывший участник команды движка Flutter, автор Flutter GPU, чтобы освободить продвинутую 3D-работу от форков движка, перенеся её в обычную экосистему Dart-пакетов; кросс-бэкендовые тесты Scene также помогают ловить регрессии Flutter GPU.
Есть ли из коробки физика и аудио?Да — физика предоставляется через бэкенды Rapier или box3d, позиционное аудио — через SoLoud или FMOD, а мультиплеер поддерживается через dashwire.
Creator
bdero
Size
24.7 MB
Stars
956
Age
2y
Commits · 90 Days