diff --git a/thermion_flutter/thermion_flutter/example/README.md b/thermion_flutter/thermion_flutter/example/README.md index 8188c29a..c5c76304 100644 --- a/thermion_flutter/thermion_flutter/example/README.md +++ b/thermion_flutter/thermion_flutter/example/README.md @@ -1,96 +1,10 @@ -For a more thorough example with both Flutter and pure Dart, see the [examples folder in the repository](https://github.com/nmfisher/thermion/tree/develop/examples). +# Examples -[flutter/quickstart/lib/main.dart](https://github.com/nmfisher/thermion/tree/develop/examples) +See the [Getting Started](https://thermion.dev/gettingstarted) and [Quickstart](https://thermion.dev/quickstart) sections of the documentation for step-by-step instructions in creating a Flutter app. + +You can also jump straight to the [Quickstart example in the repository](https://github.com/nmfisher/thermion/tree/develop/examples/flutter/quickstart/lib/main.dart) for an example of a Flutter app that uses a simple 3D viewer widget. -```dart -import 'package:flutter/material.dart'; -import 'package:thermion_flutter/thermion_flutter.dart'; +For a more advanced example, see the [Viewer example in the repository](https://github.com/nmfisher/thermion/tree/develop/examples/flutter/viewer/lib/main.dart). -import 'package:vector_math/vector_math_64.dart' as v; -import 'dart:math'; -void main() { - runApp(const MyApp()); -} - -class MyApp extends StatelessWidget { - const MyApp({super.key}); - - @override - Widget build(BuildContext context) { - return MaterialApp( - title: 'Flutter Demo', - theme: ThemeData( - colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), - useMaterial3: true, - ), - home: const MyHomePage(title: 'Flutter Demo Home Page'), - ); - } -} - -class MyHomePage extends StatefulWidget { - const MyHomePage({super.key, required this.title}); - final String title; - - @override - State createState() => _MyHomePageState(); -} - -class _MyHomePageState extends State { - bool _loaded = false; - ThermionViewer? _thermionViewer; - - @override - void initState() { - super.initState(); - } - - Future _load() async { - var viewer = await ThermionFlutterPlugin.createViewer(); - _thermionViewer = viewer; - _thermionViewer!.loadSkybox("assets/default_env_skybox.ktx"); - _thermionViewer!.loadGlb("assets/cube.glb"); - - _thermionViewer!.setCameraPosition(0, 1, 10); - _thermionViewer!.setCameraRotation( - v.Quaternion.axisAngle(v.Vector3(1, 0, 0), -30 / 180 * pi) * - v.Quaternion.axisAngle(v.Vector3(0, 1, 0), 15 / 180 * pi)); - _thermionViewer!.addLight(LightType.SUN, 7500, 50000, 0, 0, 0, 1, -1, -1); - _thermionViewer!.setRendering(true); - _loaded = true; - - setState(() {}); - } - - Future _unload() async { - var viewer = _thermionViewer!; - _thermionViewer = null; - setState(() {}); - await viewer.dispose(); - _loaded = false; - setState(() {}); - } - - Widget _loadButton() { - return Center( - child: ElevatedButton(child: const Text("Load"), onPressed: _load)); - } - - Widget _unloadButton() { - return Center( - child: ElevatedButton(child: const Text("Unload"), onPressed: _unload)); - } - - @override - Widget build(BuildContext context) { - return Stack(children: [ - if (_thermionViewer != null) - Positioned.fill(child: ThermionWidget(viewer: _thermionViewer!)), - if (!_loaded) _loadButton(), - if (_loaded) _unloadButton(), - ]); - } -} -```