diff --git a/docs/viewer.mdx b/docs/viewer.mdx index 66229d10..0954d530 100644 --- a/docs/viewer.mdx +++ b/docs/viewer.mdx @@ -1,6 +1,6 @@ ## Quickstart (Flutter) -> You can find the entire project below in the [examples/flutter/quickstart](https://github.com/nmfisher/thermion/tree/master/examples/flutter/quickstart) folder of the repository. +> You can find the entire project below in the [examples/flutter/viewer](https://github.com/nmfisher/thermion/tree/master/examples/flutter/viewer) folder of the repository. 1. Switch to Flutter master channel, upgrade Flutter, create a new project, then add `thermion_flutter` as a dependency @@ -53,11 +53,11 @@ flutter ```dart class _MyAppState extends State { -  late ThermionFlutterPlugin _thermionFlutterPlugin;  late Future _thermionViewer;   void initState() {    - _thermionFlutterPlugin = ThermionFlutterPlugin();    - _thermionViewer = _thermionFlutterPlugin.createViewer();  + ThermionFlutterPlugin.createViewer().then((viewer) { + _thermionViewer = viewer; + }); } } diff --git a/examples/flutter/viewer/lib/main.dart b/examples/flutter/viewer/lib/main.dart index a8fad08f..4508c6d2 100644 --- a/examples/flutter/viewer/lib/main.dart +++ b/examples/flutter/viewer/lib/main.dart @@ -80,7 +80,7 @@ class _MyHomePageState extends State { await _thermionViewer!.loadSkybox("assets/default_env_skybox.ktx"); await _thermionViewer!.loadIbl("assets/default_env_ibl.ktx"); - await _thermionViewer!.setBackgroundColor(0, 0, 1, 1); + // await _thermionViewer!.setBackgroundColor(0, 0, 1, 1); // The underlying Filament rendering engine exposes a number of // post-processing options (anti-aliasing, bloom, etc). @@ -93,13 +93,6 @@ class _MyHomePageState extends State { // false is designed to allow you to pause rendering to conserve battery life await _thermionViewer!.setRendering(true); - // Timer.periodic(Duration(seconds: 1), (_) async { - // final rnd = Random(); - - // await camera.setLensProjection(); - // await _thermionViewer!.setBackgroundColor(rnd.nextDouble(),rnd.nextDouble(), 0, 1.0); - // }); - setState(() {}); } @@ -120,25 +113,16 @@ class _MyHomePageState extends State { child: ElevatedButton(onPressed: _load, child: const Text("Load"))); } - Widget _renderButton() { + Widget _changeBgColor() { return Center( child: ElevatedButton( onPressed: () async { - // final rnd = Random(); - // await FilamentApp.instance!.setClearColor( - // rnd.nextDouble(), rnd.nextDouble(), rnd.nextDouble(), 1.0); - // final camera = await _thermionViewer!.getActiveCamera(); - // await _thermionViewer!.setRendering(false); - - // // await camera.setLensProjection(); - // await _thermionViewer!.removeSkybox(); - // // await _thermionViewer!.setBackgroundColor(rnd.nextDouble(), 1.0, 0, 1.0); - // await _thermionViewer!.clearBackgroundImage(destroy: true); - // // await _thermionViewer!.setBackgroundImage("/Users/nickfisher/Documents/thermion/thermion_dart/test/assets/cube_texture_512x512.png"); - - // await FilamentApp.instance!.render(); + final rnd = Random(); + await _thermionViewer!.removeSkybox(); + await _thermionViewer!.setBackgroundColor( + rnd.nextDouble(), rnd.nextDouble(), rnd.nextDouble(), 1.0); }, - child: const Text("Render"))); + child: const Text("Change background color"))); } Widget _unloadButton() { @@ -153,9 +137,9 @@ class _MyHomePageState extends State { body: Stack(children: [ if (_thermionViewer != null) Positioned.fill( - child: ThermionWidget( + child: ThermionListenerWidget(inputHandler: DelegateInputHandler.fixedOrbit(_thermionViewer!), child:ThermionWidget( viewer: _thermionViewer!, - )), + ))), Align( alignment: Alignment.bottomCenter, child: Padding( @@ -165,7 +149,7 @@ class _MyHomePageState extends State { mainAxisAlignment: MainAxisAlignment.end, children: [ if (_thermionViewer == null) _loadButton(), - if (_thermionViewer != null) _renderButton(), + if (_thermionViewer != null) _changeBgColor(), if (_thermionViewer != null) _unloadButton(), ]))) ])); diff --git a/examples/flutter/viewer/macos/Runner.xcodeproj/project.pbxproj b/examples/flutter/viewer/macos/Runner.xcodeproj/project.pbxproj index b304615c..40d2c609 100644 --- a/examples/flutter/viewer/macos/Runner.xcodeproj/project.pbxproj +++ b/examples/flutter/viewer/macos/Runner.xcodeproj/project.pbxproj @@ -558,7 +558,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.14; + MACOSX_DEPLOYMENT_TARGET = 10.15; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule; @@ -641,7 +641,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.14; + MACOSX_DEPLOYMENT_TARGET = 10.15; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = macosx; @@ -691,7 +691,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - MACOSX_DEPLOYMENT_TARGET = 10.14; + MACOSX_DEPLOYMENT_TARGET = 10.15; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; SWIFT_COMPILATION_MODE = wholemodule;