I'm not sure this is even used; the backend always allocate its own internal depth/stencil buffer. There may be a final blit from the internal buffer to the render target buffer, but I haven't actually confirmed this yet
remove size checks from setImage (we are assuming the caller knows the correct size)
This also adds some monkey-patch methods to js_interop to convert Float32List to a UInt8List (but use this with care, because it will only work for emscripten-allocated objects)
all external resources should be added on the Dart side, Filament should never attempt to load these directly from the filesystem.
relativeResourcePath (called gltfPath on the Filament side) is only used for desktop loading, so this is now irrelevant.
Note that Filament must be compiled with GLTFIO_USE_FILESYSTEM=0
This is a breaking change needed to fully implement instancing and stencil highlighting.
Previously, users would work directly with entities (on the Dart side, ThermionEntity), e.g.
final entity = await viewer.loadGlb("some.glb");
However, Filament "entities" are a lower-level abstraction.
Loading a glTF file, for example, inserts multiple entities into the scene.
For example, each mesh, light, and camera within a glTF asset will be assigned an entity. A top-level (non-renderable) entity will also be created for the glTF asset, which can be used to transform the entire hierarchy.
"Asset" is a better representation for loading/inserting objects into the scene; think of this as a bundle of entities.
Unless you need to work directly with transforms, instancing, materials and renderables, you can work directly with ThermionAsset.
successfully allocating with VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT
working copying vulkan texture
successfully passing D3D texture back to Flutter
chore: Dart/Windows sample project: remove unnnecessary InvalidateRect from update()
chore: Dart/Windows sample project: add generated bindings
successfully blitting from Vulkan swapchain to D3D texture
working Vulkan texture integration with Flutter
refactor to allow disposal of resources in destructors
handle destroyTexture correctly
correctly implement surface resizing/destruction
move Windows engine to Vulkan backend and flush after creating swapchain
add vulkan + vkshaders to Windows libs
update materials with Vulkan
move Vulkan implementation to thermion_Dart
remove extras folder
thermion_flutter plugin updates
update build hook to copy .lib file to output directory and use -vulkan lib zip file
thermion_flutter cleanup
reinstate stereoscopic on Windows
add dxgi and d3d11.lib to windows header pragma
update cli_windows sample project
copy filament/vulkan headers to output directory. This was originally added to facilitate linking on Windows (where thermion_flutter_plugin.cpp needs the Vulkan-related headers), but this doesn't actually solve the problem because there's no way that I've found to get the directory structure correct in the Dart native_assets build directory unless you explicitly address each inidivual file. The current approach is therefore to just keep a permanent copy of the headers in the thermion_filament directory (meaning these will need to be updated manually if the Filament version changes). However, I decided to keep the changes to build.dart because it doesn't have much negative impact and may be helpful in future.
disable stereoscopic on Windows and disable handle use after free checks
use filament headers for thermion_flutter
throw Exception for MSAA on Windows (note that passing msaa:true for setAntiAliasing doesn't actually set MSAA on other platforms, but at least it won't cause the engine to crash)
change header include path for Windows/Vulkan
change header include path for Windows/Vulkan
add filament/vulkan headers for flutter (Windows)
ensure destroyTexture platform methods accept an integer rather than a list
handle Android/Windows swapchain creation separately
- **REFACTOR**: remove covariant keyword from createInstance args.
- **FIX**: add flush() to skybox/IBL destroy methods to ensure that textre upload callbacks are completed to avoid stalling.
- **FIX**: duplicate setting for _grid.
#### `thermion_flutter` - `v0.3.1`
- **FIX**: addDestroySwapchain argument to createViewer() (true by default). This is only used on iOS/macOS where a single swapchain is shared between all render targets.
- **DOCS**: fix typo in link.
- **DOCS**: remove code from thermion_flutter README.md and point to docs/repository example instead.
#### `thermion_flutter_method_channel` - `v0.3.1`
- **FIX**: addDestroySwapchain argument to createViewer() (true by default). This is only used on iOS/macOS where a single swapchain is shared between all render targets.
- **FIX**: addDestroySwapchain argument to createViewer() (true by default). This is only used on iOS/macOS where a single swapchain is shared between all render targets.
# Change Log
#### v0.3.0
This release involved considerable internal refactoring, allowing us to expose more Filament functionality on the Dart side. Previously, most of this functionality was
rigidly implemented in C++ and didn't allow for end-users to take advantage of Filament directly.
This also means there are a number of breaking changes from `0.2.1`. To summarize:
-`ViewerWidget` has been introduced. This is a Flutter widget for users who only need basic rendering and don't need/want to deal with camera/materials/etc directly.
- Users who want more fine-grained control than a `ViewerWidget` can still work with `ThermionViewer` and `ThermionWidget`.
- The singleton `FilamentApp.instance` exposes methods for working almost directly with the underlying Filament engine (e.g. loading custom materials from `Uint8List`, creating textures, etc).
- New interfaces have been added for `Material`, `MaterialInstance`, `Texture`, `View`, `Scene` and `Camera`.
-`ThermionAsset` replaces `ThermionEntity` as the main interface for scene objects.
- Transforms/material instances should be set directly by `asset.setTransform`, `asset.setMaterialInstanceAt`
- Material properties can be set directly on the `MaterialInstance`, e.g. `materialInstance.setParameterFloat4("baseColorFactor", 1.0, 0.0, 0.0, 1.0);
- Linux binaries have been added to `thermion_dart`. This package can be run on Linux (which we are using for CI and automated testing) but there are not yet any Flutter bindings, so `thermion_flutter` cannot run on Linux yet.
- On Windows, `thermion_flutter` now uses the Vulkan backend. This is still experimental and will have limited supported on older hardware (pre-2018).
- Web support for `thermion_dart` has now reached parity with other platforms, though should still be considered experimental. Some manual steps are required to run in a Flutter app or a Dart web app.
> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project.
-`thermion_flutter_web` - `v0.2.0+11`
---
#### `thermion_dart` - `v0.2.1-dev.20.0`
- **FIX**: only use Windows-style ndkRoot when building on Windows.
> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project.
> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project.
> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project.
- **FIX**: remove superfluous ceil() calls for picking coordinates.
- **FIX**: remove superfluous ceil() calls for picking coordinates.
- **FIX**: reduce size of pick functor for compatibility with armeabi-v7a.
- **FIX**: reduce size of pick functor for compatibility with armeabi-v7a.
- **FEAT**: add Dart methods for getRenderableBoundingBox, setParameterInt and setParameterFloat4.
- **FEAT**: Rename Gizmo material to UnlitFixedSize, and expose methods for using this material on other entities. Also exposes new methods for setting single float parameters.
- **FEAT**: expose zoomSensitivity argument for flight input handler.
- **FEAT**: Rename Gizmo material to UnlitFixedSize, and expose methods for using this material on other entities. Also exposes new methods for setting single float parameters.
- **FEAT**: expose zoomSensitivity argument for flight input handler.
- **FEAT**: sanitize file paths in build.dart for Windows compatibility.
- **FEAT**: pass through fragment coordinates for picking.
- **FEAT**: sanitize file paths in build.dart for Windows compatibility.
- **FEAT**: pass through fragment coordinates for picking.
#### `thermion_flutter` - `v0.2.1-dev.17`
- **FIX**: multiply coordinates by pixelRatio for scale events.
- **FIX**: multiply coordinates by pixelRatio for scale events.
> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project.
- **FEAT**: Rename Gizmo material to UnlitFixedSize, and expose methods for using this material on other entities. Also exposes new methods for setting single float parameters.
> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project.
> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project.
> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project.
> Packages listed below depend on other packages in this workspace that have had changes. Their versions have been incremented to bump the minimum dependency versions of the packages they depend upon in this project.
RUN ./build.sh -l -i -f -p desktop release tinyexr
RUN ./build.sh -l -i -f -p desktop release imageio
RUN zip -r filament-v1.58.0-linux-release.zip /opt/filament/out/release/filament/lib/x86_64/*.a /opt/filament/out/cmake-release/third_party/tinyexr/tnt/libtinyexr.a /opt/filament/out/cmake-release/libs/imageio/libimageio.a
// Finally, you need to explicitly enable rendering. Setting rendering to
// false is designed to allow you to pause rendering to conserve battery life
await _thermionViewer!.setRendering(true);
```
and then in your Flutter application:
```
@override
Widgetbuild(BuildContextcontext){
Widgetbuild(BuildContextcontext){
return Stack(children: [
returnScaffold(
if (_thermionViewer != null)
body:Stack(children:[
Positioned.fill(
Positioned.fill(
child: ThermionWidget(
child:ViewerWidget(
viewer: _thermionViewer!,
assetPath:"assets/cube.glb",
)),
skyboxPath:"assets/default_env_skybox.ktx",
]);
iblPath:"assets/default_env_ibl.ktx",
transformToUnitCube:true,
initialCameraPosition:Vector3(0,0,6),
background:Colors.blue,
manipulatorType:ManipulatorType.ORBIT,
onViewerAvailable:(viewer)async{
awaitFuture.delayed(constDuration(seconds:5));
awaitviewer.removeSkybox();
},
initial:Container(
color:Colors.red,
),
))]));
}
}
```
```
> the first time you build an app that consumes this package, the Dart native-assets build system will download static binaries from Cloudflare. This may take a few minutes (depending on which platform you are compiling for). These will be cached, so subsequent builds will be much faster.
### Sponsors, Contributors & Acknowledgments
### Sponsors, Contributors & Acknowledgments
Thermion uses the [Filament](https://github.com/google/filament) Physically Based Rendering engine under the hood.
Thermion uses the [Filament](https://github.com/google/filament) Physically Based Rendering engine under the hood.
@@ -88,4 +78,5 @@ Thank you to the following people:
-@daverin for MacOS library contributions
-@daverin for MacOS library contributions
-@LukasPoque for CI/refactoring work
-@LukasPoque for CI/refactoring work
-@alexmercerind for his work on integrating ANGLE textures on Flutter Windows
-@alexmercerind for his work on integrating ANGLE textures on Flutter Windows
`ThermionListenerWidget` is a very simple widget; it simply forwards pointer, gesture and keyboard events to the provided [InputHandler], which must decide how to interpret those events.
For example, one [InputHandler] implementation might interpret mouse pointer movement as "rotate the camera", whereas a separate implementation might interpret it as "translate this specific entity".
Thermion provides two default InputHandler implementations for manipulating the camera: [DelegateInputHandler.fixedOrbit] and [DelegateInputHandler.flight].
[DelegateInputHandler.fixedOrbit] will rotate the camera in a fixed orbit around a target point (the origin, by default), and also allow zooming in/out (subject to a minimum distance, which is configurable).
By default, [DelegateInputHandler.fixedOrbit] will:
- rotate the camera when the middle mouse button is held and the pointer is moved (on desktop), and when a single swipe left/right/up/down is detected (on mobile)
- zoom the camera when the scroll wheel is scrolled up/down (on desktop), and when a pinch gesture is detected (on mobile)
You can change the action for a specific input type by calling `setActionForType`; for example, if you wanted to rotate the camera by moving the mouse pointer while holding the left mouse button, you would call:
See the [InputType] and [InputAction] enums for available input types and actions.
[DelegateInputHandler.flight] will translate keyboard and mouse/touchscreen gestures to free flight camera manipulation.
By default:
- holding the middle mouse button will control the pitch/roll/yaw of the camera
- holding the left mouse button will pan the camera left/right/up/down
- the middle mouse button will zoom/dolly the camera in/out
- the WASD keys will pan the camera left/right/up/down and dolly the camera forward/backward
If these don't exactly fit your use case, you can create your own [InputHandler] implementation. If you think it would be useful to other users, please feel free to submit a PR for your implementation to be included in the base Thermion package.
If something is crashing or not working as expected, you can enable verbose logging and/or debug builds (particularly useful for debugging with lldb or getting legible stack traces):
Add a `hooks` section to your app's `pubspec.yaml`, e.g.
```
name: example_cli
description: A sample command-line application.
version: 1.0.0
environment:
sdk: ^3.3.0
# Add the below
hooks:
user_defines:
thermion_dart:
mode: debug
tracing: enabled
```
After changing the `hooks` section, make sure you run `flutter clean` to propagate the changes correctly.
> [!CAUTION]
> Debug builds won't work for Android. This is a known upstream issue with Filament.
Unless `mode: debug` is specified in your `pubspec.yaml`, Thermion will use release builds under the hood, even if your app is compiled/runing in debug mode.
@@ -16,7 +16,7 @@ Thermion is divided into two packages:
With this structure, the Flutter-specific components are not coupled to the Dart components, meaning Thermion can be used for rendering in both Flutter and non-Flutter applications.
With this structure, the Flutter-specific components are not coupled to the Dart components, meaning Thermion can be used for rendering in both Flutter and non-Flutter applications.
For example, Thermion ships with examples for rendering with Dart only (no Flutter) with a CLI/headless application on MacOS, and with a Javascript/WASM/HTML applicaiton in browsers.
For example, Thermion ships with examples for rendering with Dart only (no Flutter) with a CLI/headless application on MacOS, and with a Javascript/WASM/HTML application in browsers.
`thermion_flutter` exports `thermion_dart`, so if you are working with a Flutter application, you will only need to import `thermion_fluttter`.
`thermion_flutter` exports `thermion_dart`, so if you are working with a Flutter application, you will only need to import `thermion_fluttter`.
Thermion requires a minimum iOS version of 13.0. When building a Flutter application, ensure your application's `ios/Podfile` contains the following:
```ruby
platform :ios, '13.0'
```
and in ios/Info.plist:
```xml
<key>LSMinimumSystemVersion</key>
<string>13.0</string>
```
When submitting to the App Store, you may encounter an error saying `thermion_dart.framework does not supported the minimum deployment target in Info.plist`.
This is because Flutter hardcodes a deployment target of iOS 12.0 when invoking the native assets build, which conflicts with actual requirement.
After running `flutter build ios` (but before archiving the build and submitting to the App Store), run the following script to replace the `MinimumOSVersion`:
```
#!/bin/zsh
# Array of directories containing Info.plist files
Currently, only the Dart package (`thermion_dart`) will work on Linux (primarily for the automated build/testing pipeline).
Filament has been built for Ubuntu 22.04; other distributions may work, but YMMV.
The Flutter package (`thermion_flutter`) won't work; it's missing the platform glue code necessary to set up the render target. Support will eventually be added, but there is currently no estimated timeline.
Contributions are welcome and it's actually not a lot of work. Join the Discord if you want to help out.
> You can find the entire project below in the [flutter/quickstart](https://github.com/nmfisher/thermion_examples/tree/master/flutter/quickstart) folder of the `thermion_examples` repository.
If all you need is a quick and easy route to rendering a single 3D model in your Flutter application, start with `ViewerWidget`.
1. Switch to Flutter master channel, upgrade Flutter, create a new project, then add `thermion_flutter` as a dependency
This is a simplified, Flutter-only wrapper around the underlying 3D rendering API with sane defaults for most people.
```bash
`ViewerWidget` handles all the setup and configuration of the underlying Thermion API, including:
$ flutter channel master
- Loading 3D models (glTF assets)
$ flutter upgrade
- Configuring skyboxes and image-based lighting
$ flutter config --enable-native-assets
- Setting up camera positions and manipulators
$ flutter create thermion_sample_project && cd thermion_sample_project
- Managing the rendering lifecycle
$ flutter pub add thermion_flutter
```
2. If running on iOS or MacOS, change the minimum deployment target to OSX 13
## Setup
<Accordion title="Click to open iOS/MacOS instructions">
Follow the steps listed in [Getting Started](./getting_started) to configure your Flutter installation and project.
Make sure the `platform` entry refers to `13.0` in your Podfile.
Here, we've added a skybox (the background (cube) image rendered behind all other elements in the scene), image-based lighting (where an image is used to determine the direction and intensity of a light source) and a directional light (Sun).
## Limitations
Anything added to the scene is referred to as an "entity" (including lights and cameras).
- Only the `manipulatorType` property can be changed at runtime. For any other property changes, create a new widget.
- The widget requires that you have the correct environment setup for Thermion (Flutter master channel with native assets enabled).
Entities are always added to the scene at position (0,0,0).
## Example
The default scene camera is located at (0,0,0) (and is looking at -Z, or "into" the screen), so by adding a cube at (0,0,0), the camera will now be inside the cube.
Here's a complete example showing how to use `ViewerWidget` with multiple configuration options:
We need to move the camera outside the cube so it's visible.
The cube still won't be visible until we add a light to the scene and tell Thermion to start rendering.
7. Add a light and turn rendering on
```dart
...
await viewer.addLight(
LightType.SUN, 7500, 50000, 0, 0, 0, 1, -1, -1);
await viewer.setRendering(true);
...
````
8. Run the project
```
$ flutter run -d macos
```
> You may experience a noticeable delay the very first time you run the project. Don't panic, it's not frozen! This is due to the build system downloading the prebuilt Filament binaries from Cloudflare, which can take some time (particularly on Windows). These binaries will be cached after first download, so subsequent runs will be much faster (though every time you run flutter clean, the binaries will be re-downloaded).

A basic HTML + Dart site for viewing KTX textures in browser.
## DartPad Playground
## DartPad Playground
A custom DartPad that lets you experiment with Thermion from your browser (currently, only Chrome is supported).
A custom DartPad that lets you experiment with Thermion from your browser (currently, only Chrome is supported).
[](https://dartpad.thermion.dev)
[](https://dartpad.thermion.dev)
(Outdated, needs to be upgraded to Thermion `0.3.0`);
## mixreel (Flutter/Web)
## mixreel (Flutter/Web)
Create 3D worlds and translate to AI video.
Create 3D worlds and translate to AI video.
[](https://mixreel.ai)
[](https://mixreel.ai)
## Nick Fisher
## Nick Fisher
My personal website, where I create an interactive clone of myself with Avaturn & Cartesia (no Flutter, made with Thermion and the [Jaspr Dart UI framework](https://github.com/schultek/jaspr)).
My personal website, where I create an interactive clone of myself with Avaturn & Cartesia (no Flutter, made with Thermion and the [Jaspr Dart UI framework](https://github.com/schultek/jaspr)).
@@ -21,3 +28,4 @@ My personal website, where I create an interactive clone of myself with Avaturn
If you just want to display a 3D object in the viewport with some basic camera controls, use the [ViewerWidget described in the Quickstart section](./quickstart).
If you need want more fine-grained control
> 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.
2. Add a folder containing your assets (glTF model + skybox ktx) to your `pubspec.yaml` asset list
```yaml
...
flutter
assets:
- assets/
```
3. Create an instance of `ThermionFlutterPlugin` in your app.
Here, we've added a skybox (the background (cube) image rendered behind all other elements in the scene), image-based lighting (where an image is used to determine the direction and intensity of a light source) and a directional light (Sun).
Anything added to the scene is referred to as an "entity" (including lights and cameras).
Entities are always added to the scene at position (0,0,0).
The default scene camera is located at (0,0,0) (and is looking at -Z, or "into" the screen), so by adding a cube at (0,0,0), the camera will now be inside the cube.
We need to move the camera outside the cube so it's visible.
The cube still won't be visible until we add a light to the scene and tell Thermion to start rendering.
7. Add a light and turn rendering on
```dart
...
await viewer.addLight(
LightType.SUN, 7500, 50000, 0, 0, 0, 1, -1, -1);
await viewer.setRendering(true);
...
````
8. Run the project
```
$ flutter run -d macos
```
> You may experience a noticeable delay the very first time you run the project. Don't panic, it's not frozen! This is due to the build system downloading the prebuilt Filament binaries from Cloudflare, which can take some time (particularly on Windows). These binaries will be cached after first download, so subsequent runs will be much faster (though every time you run flutter clean, the binaries will be re-downloaded).

Some files were not shown because too many files have changed in this diff
Show More
Reference in New Issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.