flutter_scene 0.18.1 copy "flutter_scene: ^0.18.1" to clipboard
flutter_scene: ^0.18.1 copied to clipboard

A powerful and flexible realtime 3D rendering engine for Flutter.

example/README.md

Flutter Scene example #

A minimal scene: load a glTF model and display it with a PerspectiveCamera through SceneView.

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

class ModelView extends StatefulWidget {
  const ModelView({super.key});
  @override
  State<ModelView> createState() => _ModelViewState();
}

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

  @override
  void initState() {
    super.initState();
    // Static resources (shader bundle, BRDF LUT) load asynchronously.
    Scene.initializeStaticResources().then((_) async {
      final model = await Node.fromGlbAsset('assets/model.glb');
      scene.add(model);
      if (mounted) setState(() => ready = true);
    });
  }

  @override
  Widget build(BuildContext context) {
    if (!ready) return const Center(child: CircularProgressIndicator());
    // SceneView renders the scene and drives its per-frame loop; no
    // hand-written CustomPainter is needed.
    return SceneView(
      scene,
      camera: PerspectiveCamera(
        position: vm.Vector3(0, 2, 5),
        target: vm.Vector3(0, 0, 0),
      ),
    );
  }
}

For an animated camera, pass cameraBuilder: (elapsed) => ... instead of a fixed camera.

To preprocess models offline and hot reload them (and .fmat materials) in place, load by source path with loadModel / loadFmatMaterial and a DataAssets build hook. For a full runnable app exercising materials, skinning/animation, custom shaders, and hot reload, see examples/flutter_app.

207
likes
160
points
2.25k
downloads
screenshot

Documentation

API reference

Publisher

verified publisherbdero.dev

Weekly Downloads

A powerful and flexible realtime 3D rendering engine for Flutter.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

args, collection, data_assets, flat_buffers, flutter, flutter_gpu, flutter_gpu_shaders, hooks, image, logging, vector_math, web

More

Packages that depend on flutter_scene