initial work to split into dart_filament and flutter_filament
This commit is contained in:
172
.gitattributes
vendored
172
.gitattributes
vendored
@@ -1,12 +1,160 @@
|
||||
*.a filter=lfs diff=lfs merge=lfs -text
|
||||
*.lib filter=lfs diff=lfs merge=lfs -text
|
||||
*.dll filter=lfs diff=lfs merge=lfs -text
|
||||
*.pdb filter=lfs diff=lfs merge=lfs -text
|
||||
*.png filter=lfs diff=lfs merge=lfs -text
|
||||
*.jpg filter=lfs diff=lfs merge=lfs -text
|
||||
*.uberz filter=lfs diff=lfs merge=lfs -text
|
||||
*.bin filter=lfs diff=lfs merge=lfs -text
|
||||
*.ktx filter=lfs diff=lfs merge=lfs -text
|
||||
*.blend filter=lfs diff=lfs merge=lfs -text
|
||||
*.gltf filter=lfs diff=lfs merge=lfs -text
|
||||
*.glb filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libbackendtest_combined.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libfilabridge.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libgltfio_core.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libibl-lite.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libcamutils.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libgeometry_combined.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios/libbackend.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios/libuberarchive.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libbasis_transcoder.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libgeometry.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libmikktspace.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios/libzstd.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libcivetweb.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libsdl2.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libmeshoptimizer.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libmathio.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios/libbasis_transcoder.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libfilament-iblprefilter.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libmatdbg_combined.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libspirv-cross-msl.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libtinyexr.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libzstd.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios/libshaders.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libSPIRV-Tools.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libgeometry.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libimageio.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libOGLCompiler.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libSPIRV-Tools-diff.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libfilamat_combined.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libfilameshio.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libmathio.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libshaders.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libassimp.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libmatlang.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libibl.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libmikktspace.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libmatdbg_combined.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/swift/DartFilamentTexture.h filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libfilamat_combined.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libfilament.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libibl.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libstb.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libuberzlib.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libbasis_encoder.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libimgui.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libdracodec.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libimageio.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios/libfilament.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios/libstb.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libbackend_test.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libgetopt.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libgtest.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libfilabridge.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libmatdbg_resources.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libuberarchive.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios/libfilaflat.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libSPIRV.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libpng.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libvkshaders.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios/libutils.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libimage.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libmatdbg_resources.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libsuzanne-resources.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libfilamat_lite.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libgeometry_combined.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libshaders.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libsmol-v.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libmath.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios/libgeometry.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios/libmeshoptimizer.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios/libpng16.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libbenchmark_main.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libbluegl.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libuberzlib.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/swift/build.sh filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios/libdracodec.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios/libibl.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libktxreader.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libbluegl.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libfilaflat.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libpng.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libbluevk.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libfilaflat.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libfilamat.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libglslang.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libcivetweb.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios/libktxreader.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libbenchmark.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libgltf-demo-resources.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libgltfio_core.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libSPIRV-Tools-lint.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libdracodec.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libfilagui.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios/libmikktspace.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libsample-resources.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libOSDependent.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libspirv-cross-glsl.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libgltfio.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios/libimage.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios/libpng.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libgltfio.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libmatdbg.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libspirv-cross-core.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libstb.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libfilamat.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libfilamat_lite.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios/libfilamat.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios/libviewer.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libutils.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios/libvkshaders.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libcamutils.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libbackend.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libfilagui.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libmath.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libviewer.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/swift/libdartfilamenttexture.dylib filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios/libfilament-iblprefilter.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios/libuberzlib.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libutils.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libviewer.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios/libfilamat_lite.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios/libfilameshio.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios/libcivetweb.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libbasis_transcoder.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libSPIRV-Tools-link.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libvkshaders.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libz.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libbluevk.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libtinyexr.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libzstd.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios/libcamutils.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios/libfilabridge.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libmatdbg.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libimage.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libsmol-v.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios/libgltfio_core.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios/libsmol-v.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libfilament-iblprefilter.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libfilament.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libmeshoptimizer.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libbackend.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libibl-lite.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/libktxreader.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libfilameshio.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/swift filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios/libtinyexr.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libSPIRV-Tools-reduce.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/macos/debug/libuberarchive.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios/libibl-lite.a filter=lfs diff=lfs merge=lfs -text
|
||||
dart_filament/native/lib/ios/libimageio.a filter=lfs diff=lfs merge=lfs -text
|
||||
materials/Makefile filter=lfs diff=lfs merge=lfs -text
|
||||
materials/gizmo.filamat filter=lfs diff=lfs merge=lfs -text
|
||||
materials/gizmo.mat filter=lfs diff=lfs merge=lfs -text
|
||||
materials/image.filamat filter=lfs diff=lfs merge=lfs -text
|
||||
materials/image.mat filter=lfs diff=lfs merge=lfs -text
|
||||
materials/unlit_fade.mat filter=lfs diff=lfs merge=lfs -text
|
||||
materials/unlit_opaque.mat filter=lfs diff=lfs merge=lfs -text
|
||||
|
||||
6
.gitignore
vendored
6
.gitignore
vendored
@@ -1,4 +1,4 @@
|
||||
.dart_tool
|
||||
**/.dart_tool
|
||||
.vscode
|
||||
macos/src
|
||||
macos/include
|
||||
.DS_Store
|
||||
.DS_Store
|
||||
|
||||
21
Makefile
21
Makefile
@@ -1,21 +0,0 @@
|
||||
# building on MacOS, we currently just delete the macos/include
|
||||
# and macos/src directories and copy from iOS
|
||||
sync-macos: FORCE
|
||||
rm -rf ${current_dir}macos/include ${current_dir}macos/src
|
||||
cp -R ${current_dir}ios/include ${current_dir}macos
|
||||
cp -R ${current_dir}ios/src ${current_dir}macos
|
||||
|
||||
# We compile a small set of custom materials for various helpers (background image, gizmo, etc)
|
||||
# You must specify the `FILAMENT_PATH` environment variable, either the path /out/release
|
||||
# eg: FILAMENT_PATH=/path/to/filament/out/release/bin make materials
|
||||
#
|
||||
materials: FORCE
|
||||
@echo "Using Filament build from ${FILAMENT_PATH}"
|
||||
${FILAMENT_PATH}/matc -a opengl -a metal -o materials/image.filamat materials/image.mat
|
||||
$(FILAMENT_PATH)/resgen -c -p image -x ios/include/material/ materials/image.filamat
|
||||
$(FILAMENT_PATH)/matc -a opengl -a metal -o materials/gizmo.filamat materials/gizmo.mat
|
||||
$(FILAMENT_PATH)/resgen -c -p gizmo -x ios/include/material/ materials/gizmo.filamat
|
||||
#rm materials/*.filamat
|
||||
|
||||
FORCE: ;
|
||||
|
||||
449
dart_filament/README.md
Normal file
449
dart_filament/README.md
Normal file
@@ -0,0 +1,449 @@
|
||||
# Flutter Filament
|
||||
|
||||
Cross-platform, 3D PBR rendering and animation for [Flutter](https://github.com/google/filament).
|
||||
|
||||
Wraps the [the Filament rendering library](https://github.com/google/filament).
|
||||
|
||||
Powers the [Polyvox](https://polyvox.app) and [odd-io](https://github.com/odd-io/) engines.
|
||||
|
||||
This is still in beta: bugs/missing features are to be expected.
|
||||
|
||||
https://github.com/nmfisher/flutter_filament/assets/7238578/abaed1c8-c97b-4999-97b2-39e85e0fa7dd
|
||||
|
||||
|
||||
|Feature|Supported|
|
||||
|---|---|
|
||||
|Platforms|✅ iOS (arm64)<br/>✅ MacOS (arm64)<br/>✅ Android (arm64) <br/>✅ Windows (x64) (>= 10)<br/>⚠️ Linux (x64 - broken)<br/>⚠️ Web (planned)|
|
||||
|Formats|✅ glb <br/>⚠️ glTF (partial - see Known Issues)|
|
||||
|Texture support|✅ PNG <br/>✅ JPEG <br/>✅ KTX <br/>⚠️ KTX2 (planned)|
|
||||
|Camera movement|✅ Desktop (mouse)<br/>✅ Mobile (swipe/pinch)|
|
||||
|Animation|✅ Embedded glTF skinning animations<br/>✅ Embedded glTF morph animations<br/> ✅ Runtime/dynamic morph animations<br/> ⚠️ Runtime/dynamic skinning animations <br/>
|
||||
|Entity manipulation|✅ Viewport selection<br/>⚠️ Entity/transform parenting (planned)<br/> ⚠️ Transform manipulation (mouse/gesture to rotate/translate/scale object) (partial)<br/>⚠️ Runtime material changes (planned)|
|
||||
|
||||
Special thanks to [odd-io](https://github.com/odd-io/) for sponsoring work on supporting Windows, raycasting, testing and documentation.
|
||||
|
||||
PRs are welcome but please create a placeholder PR to discuss before writing any code. This will help with feature planning, avoid clashes with existing work and keep the project structure consistent.
|
||||
|
||||
## Getting Started
|
||||
|
||||
This package requires Flutter >= `3.16.0-0.2.pre`, so you will need to first switch to the `beta` channel:
|
||||
|
||||
```
|
||||
flutter channel beta
|
||||
flutter upgrade
|
||||
```
|
||||
There are specific issues with earlier versions on Windows/MacOS (mobile should actually be fine, so if you want to experiment on your own you're free to remove the minimum version from `pubspec.yaml`).
|
||||
|
||||
Next, clone this repository and pull the latest binaries from Git LFS:
|
||||
|
||||
```
|
||||
cd $HOME
|
||||
git clone <repo> && cd flutter_filament
|
||||
git lfs pull
|
||||
```
|
||||
|
||||
(this step won't be needed after the plugin is published to pub.dev).
|
||||
|
||||
> You *do not need to build Filament yourself*. The repository is bundled with all necessary headers/static libraries (`windows/lib`, `ios/lib`, `macos/lib` and `linux/lib`) and the Flutter plugin has been configured to link at build time.
|
||||
|
||||
Run the example project to check:
|
||||
|
||||
```
|
||||
cd example && flutter run -d <macos/windows/Your iPhone/etc>
|
||||
```
|
||||
|
||||
To use the plugin in your own project, add the plugin to your pubspec.yaml:
|
||||
|
||||
```
|
||||
name: your_project
|
||||
description: Your project
|
||||
...
|
||||
dependencies:
|
||||
flutter:
|
||||
sdk: flutter
|
||||
flutter_filament:
|
||||
path: <path where you cloned the repository>
|
||||
```
|
||||
|
||||
## Basic Usage
|
||||
|
||||
See the `example` project for a complete sample that incorporates many of the below steps, and more.
|
||||
|
||||
### Creating the viewport widget and controller
|
||||
|
||||
Create an instance of `FilamentControllerFFI` somewhere in your app where it will not be garbage collected until you no longer need a rendering canvas:
|
||||
|
||||
```
|
||||
class MyApp extends StatelessWidget {
|
||||
|
||||
final _filamentController = FilamentControllerFFI();
|
||||
...
|
||||
}
|
||||
|
||||
```
|
||||
|
||||
This is a relatively lightweight object, however its constructor will load/bind symbols from the native library. This may momentarily block the UI, so you may wish to structure your app so that this is hidden behind a static widget until it is available.
|
||||
|
||||
Next, create an instance of `FilamentWidget` in the widget hierarchy where you want the rendering canvas to appear. This can be sized as large or as small as you want. On most platforms, Flutter widgets can be positioned above or below the `FilamentWidget`.
|
||||
|
||||
```
|
||||
class MyApp extends StatelessWidget {
|
||||
|
||||
final _filamentController = FilamentControllerFFI();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
color: Colors.white,
|
||||
home: Scaffold(backgroundColor: Colors.white, body: Stack(children:[
|
||||
Container(color:Colors.green, height:100, width:100),
|
||||
Positioned.fill(top:100, left:100child:FilamentWidget(controller:_filamentController)),
|
||||
Positioned(right:0, bottom:0, child:Container(color:Colors.purple, height:100, width:100))
|
||||
])));
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
When a `FilamentWidget` is added to the widget hierarchy:
|
||||
1) by default a Container will be rendered with solid red. If you want to change this, pass a widget as the `initial` paramer to the `FilamentWidget` constructor.
|
||||
2) on the second frame, `FilamentWidget` will pass its dimensions/pixel ratio to the `FilamentController`
|
||||
3) You can then call `createViewer` to create:
|
||||
* the rendering surface (on most platforms, a backing texture that will be registered with Flutter for use in a `Texture` widget)
|
||||
* a rendering thread
|
||||
* a `FilamentViewer` and an `SceneManager`, which will allow you to load assets/cameras/lighting/etc via the `FilamentController`
|
||||
4) after an indeterminate number of frames, `FilamentController` will notify `FilamentWidget` when a rendering surface is available the viewport
|
||||
5) `FilamentWidget` will replace the default `initial` Widget with the viewport (which will initially be solid black or white, depending on your platform).
|
||||
|
||||
IMPORTANT: there *will* be a delay between adding a `FilamentWidget`, calling `createViewer` and the actual rendering viewport becoming available. This is why we fill `FilamentWidget` with red - to make it abundantly clear that you need to handle this asynchronous delay appropriately. Once `createViewer` has completed, the viewport is available for rendering.
|
||||
|
||||
> Currently, the `initial` widget will also be displayed whenever the viewport is resized (including changing orientation on mobile and drag-to-resize on desktop). You probably want to change this from the default red.
|
||||
|
||||
Congratulations! You now have a scene. It's completely empty, so you probably want to add something visible.
|
||||
|
||||
### Load a background
|
||||
|
||||
You probably want to set a background for your scene. You can load a skybox:
|
||||
```
|
||||
await _filamentController.loadSkybox("assets/default_env/default_env_skybox.ktx)
|
||||
```
|
||||
|
||||
or a static background image:
|
||||
|
||||
```
|
||||
await _filamentController.setBackgroundImage("assets/background.ktx)
|
||||
```
|
||||
|
||||
or a solid background color:
|
||||
|
||||
```
|
||||
await _filamentController.setBackgroundColor(0.0, 1.0, 0.0, 1.0); // solid green
|
||||
```
|
||||
|
||||
At this point, you might not see any change in the viewport. This is because the FilamentController will only actually render into the viewport once `render` has been called.
|
||||
|
||||
By default, the FilamentController will only render into the viewport by manually calling `render()` on the FilamentController. This is to avoid needlessly running a render loop when there is nothing to display.
|
||||
|
||||
```
|
||||
await _filamentController.render()
|
||||
```
|
||||
|
||||
You should now see your background displayed in the scene. To automatically render at 60fps, call `setRendering`:
|
||||
```
|
||||
await _filamentController.setRendering(true);
|
||||
```
|
||||
|
||||
### Load an asset
|
||||
|
||||
To add a glTF asset to the scene, call `loadGlb()` on `FilamentController` with the Flutter asset path to your .glb file.
|
||||
|
||||
For example, if your `pubspec.yaml` looks like this:
|
||||
```
|
||||
flutter:
|
||||
assets:
|
||||
- assets/models/bob.glb
|
||||
```
|
||||
|
||||
Then you would call the following
|
||||
```
|
||||
var entity = await _filamentController.loadGlb("assets/models/bob.glb");
|
||||
```
|
||||
You can also pass a URI to indicate that the glTF file should be loaded from the filesystem:
|
||||
```
|
||||
var entity = await _filamentController.loadGlb("file:///tmp/bob.glb");
|
||||
```
|
||||
|
||||
The return type `FilamentEntity` is simply an integer handle that be used to manipulate the entity in the scene. For example, to remove the asset:
|
||||
```
|
||||
await _filamentController.removeEntity(entity);
|
||||
entity = null;
|
||||
```
|
||||
> Removing an entity from the scene will invalidate the corresponding `FilamentEntity` handle, so ensure you don't retain any references to it after calling `removeEntity` or `clearEntities`. Removing one `FilamentEntity` does not invalidate/change any other `FilamentEntity` handles; you can continue to safely manipulate these via the `FilamentController`.
|
||||
|
||||
### Lighting
|
||||
|
||||
You should now see your object in the viewport, but since we haven't added a light, this will be solid black.
|
||||
|
||||
Add an image-based light from a KTX file:
|
||||
|
||||
```
|
||||
await _filamentController.loadIbl("assets/default_env/default_env_ibl.ktx");
|
||||
```
|
||||
|
||||
You can also add dynamic lights:
|
||||
|
||||
```
|
||||
var sun = await _filamentController.addLight(
|
||||
```
|
||||
|
||||
### Manipulating entity transforms
|
||||
|
||||
To set the world space position of the asset:
|
||||
```
|
||||
_filamentController.setPositon(entity, 1.0, 1.0, 1.0);
|
||||
```
|
||||
|
||||
On desktop, you can also click any renderable object in the viewport to retrieve its associated FilamentEntity (see below).
|
||||
|
||||
### Camera movement
|
||||
|
||||
To enable mouse/swipe navigation through the scene, wrap the `FilamentWidget` inside a `FilamentGestureDetector`:
|
||||
|
||||
```
|
||||
class MyApp extends StatelessWidget {
|
||||
|
||||
final _filamentController = FilamentControllerFFI();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
color: Colors.white,
|
||||
home: Scaffold(backgroundColor: Colors.white, body: Stack(children:[
|
||||
Positioned.fill(child:FilamentGestureDetector(
|
||||
controller: _filamentController,
|
||||
child:FilamentWidget(
|
||||
controller:_filamentController
|
||||
))),
|
||||
Positioned(right:0, bottom:0, child:Container(color:Colors.purple, height:100, width:100))
|
||||
])));
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
On desktop:
|
||||
1) hold the middle mouse button and move the mouse to rotate the camera
|
||||
2) hold the left mouse button and move the mouse to pan the camera
|
||||
3) scroll up/down with the scrollwheel to zoom in/out.
|
||||
|
||||
On mobile:
|
||||
1) swipe with your finger to pan the camera
|
||||
2) double tap the viewport, then swipe with your finger to rotate the camera (double-tap again to return to pan)
|
||||
3) pinch with two fingers in/out to zoom in/out.
|
||||
|
||||
### Changing the active camera
|
||||
|
||||
Every scene has a default camera. Whenever you rotate/pan/zoom the viewport, you are moving the default camera.
|
||||
|
||||
If you have added an entity to the scene that contains one or more camera nodes, you can change the active scene camera to one of those camera nodes.
|
||||
|
||||
```
|
||||
var asset = await _filamentController.loadGlb("assets/some_asset_with_camera.glb");
|
||||
await _filamentController.setCamera(asset, "Camera.002"); // pass the node name to load a specific camera under that entity node
|
||||
await _filamentController.setCamera(asset, null); // pass null to load the first camera found under that entity
|
||||
```
|
||||
|
||||
### Picking entities
|
||||
|
||||
On desktop, left-clicking an object in the viewport will retrieve the FilamentEntity for the top-most renderable instance at that cursor position (if any).
|
||||
|
||||
Note this is an asynchronous operation, so you will need to subscribe to the [pickResult] stream on your [FilamentController] to do something with the result.
|
||||
|
||||
```
|
||||
class MyApp extends StatefulWidget {
|
||||
...
|
||||
}
|
||||
|
||||
|
||||
class _MyAppState extends State<MyApp> {
|
||||
|
||||
final _filamentController = FilamentControllerFFI();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
_filamentController.pickResult.listen((FilamentEntity filamentEntity) async {
|
||||
var entityName = _filamentController.getNameForEntity(filamentEntity);
|
||||
await showDialog(builder:(ctx) {
|
||||
return Container(child:Text("You clicked $entityName"));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
color: Colors.white,
|
||||
home: Scaffold(backgroundColor: Colors.white, body: Stack(children:[
|
||||
Positioned.fill(child:FilamentGestureDetector(
|
||||
controller: _filamentController,
|
||||
child:FilamentWidget(
|
||||
controller:_filamentController
|
||||
))),
|
||||
])));
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Advanced Usage
|
||||
|
||||
If you want to work with custom materials, you will need some (basic knowledge of the underlying Filament library)[https://google.github.io/filament/Materials.html#compilingmaterials].
|
||||
|
||||
Things to keep in mind:
|
||||
- You must compile materials with the correct version of Filament (see the table above). Keep in mind that versions may not be identical across platforms so you may need multiple uberz files for multiple platforms.
|
||||
|
||||
e.g. the lit_opaque.uberz file has been created from a Filament build:
|
||||
|
||||
```
|
||||
cd out/cmake-android-release-aarch64/libs/gltfio
|
||||
uberz -TSHADINGMODEL=lit -TBLENDING=opaque -o lit_opaque_43.uberz lit_opaque
|
||||
```
|
||||
|
||||
(note that the number in the filename corresponds to the Material version, not the Filament version. Not every Filament version requires a new Material version).
|
||||
|
||||
## Footguns
|
||||
|
||||
### Stripping in release mode
|
||||
|
||||
If you build your app in release mode, you will need to ensure that "Dead Strip" is set to false.
|
||||
|
||||
This is because we only invoke the library at runtime via FFI, so at link time these symbols are otherwise treated as redundant.
|
||||
|
||||
### Animations when backgrounded
|
||||
|
||||
Don't call playAnimation when the app is in the background (i.e inactive/hidden). This will queue, but not start, an animation, and eventually this will overflow the command buffer when the app is foregrounded/resumed.
|
||||
|
||||
If you have some kind of looping animation in your app code, make sure it pauses while the app is backgrounded.
|
||||
|
||||
|
||||
|
||||
## Versioning
|
||||
|
||||
||Android|iOS|MacOS|Windows|Linux|WebGL|
|
||||
|---|---|---|---|---|---||
|
||||
|Filament|v1.43.1 (arm64/armeabi-v7a/x86/x86_64)|v1.43.1* (arm64)|v1.43.1 (arm64)|v1.32.4 (x86_64)|TODO**|TODO***|
|
||||
|Flutter||3.15.0-15.2.pre|3.15.0-15.2.pre|3.15.0-15.2.pre
|
||||
|
||||
* iOS release build has a skybox bug so the debug versions are currently shipped on iOS
|
||||
** (Waiting for https://github.com/google/filament/issues/7078 to be resolved before upgrading, not sure exactly when the bug was introduced but it was somewhere between v1.32.4 and v1.40.0)
|
||||
*** Texture widget not currently supported on web in Flutter.
|
||||
|
||||
|
||||
## Testing
|
||||
|
||||
We automate testing by running the example project on actual iOS/Android/MacOS/Windows devices and executing various operations.
|
||||
|
||||
Eventually we want to compare screenshots after each operation to a set of goldens for every platform.
|
||||
|
||||
Currently this is only possible on iOS (see https://github.com/flutter/flutter/issues/123063 and https://github.com/flutter/flutter/issues/127306).
|
||||
|
||||
To re-generate the golden screenshots for a given device:
|
||||
|
||||
```
|
||||
./regenerate_goldens.sh <your_device_id>
|
||||
```
|
||||
To run the tests and compare against those goldens:
|
||||
```
|
||||
./compare_goldens.sh <your_device_id>
|
||||
```
|
||||
|
||||
The results will depend on the actual device used to generate the golden, therefore if you are using a different device (which is likely), your results may not be the same. This is expected.
|
||||
|
||||
# Building Filament from source
|
||||
|
||||
```
|
||||
git clone git@github.com:nmfisher/filament.git && cd filament
|
||||
```
|
||||
|
||||
## Android/iOS/MacOS
|
||||
|
||||
```
|
||||
git checkout flutter-filament-ios-android-macos
|
||||
./build.sh -p <platform> release
|
||||
```
|
||||
|
||||
## Windows
|
||||
|
||||
To support embedding GPU textures in Flutter (rather than copying to a CPU pixel buffer on every frame), we need to build a slightly customized version of Filament that uses GLES on Windows (rather than the default, which uses OpenGL).
|
||||
|
||||
Separately, we also force the Filament gltfio library to load assets via in-memory buffers, rather than the filesystem. This is simply a convenience so we don't have to use different logic for gltf resource loading across platforms.
|
||||
|
||||
```
|
||||
git checkout flutter-filament-windows
|
||||
mkdir out && cd out
|
||||
"C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe" --build . --target gltf_viewer --config Debug
|
||||
```
|
||||
|
||||
Building notes:
|
||||
On Android/iOS, we remove -fno-exceptions from CMakeLists.txt
|
||||
|
||||
Project structure:
|
||||
- most shared code/headers under ios/src (because I still can't get podspec to build a target with symlinks or relative paths)
|
||||
- building on MacOS, we currently just delete the macos/include and macos/src directories and copy from iOS (for same reason),
|
||||
e.g.
|
||||
|
||||
```
|
||||
make sync-macos
|
||||
```
|
||||
|
||||
- Note also need to specifically build imageio/png/tinyexr
|
||||
- if release build, then need to comment out -fno-exceptions
|
||||
|
||||
# Linux specific
|
||||
|
||||
(Fedora 34)
|
||||
Building Filament:
|
||||
env LIBRARY_PATH=/usr/lib/gcc/x86_64-redhat-linux/11/ CC=clang CXX=clang++ CXX_FLAGS="-v" LD_FLAGS="-v" FILAMENT_REQUIRES_CXXABI=true ./build.sh -c release
|
||||
|
||||
Running example project:
|
||||
export PKG_CONFIG_PATH=/usr/lib/pkgconfig/:/usr/lib64/pkgconfig/ CPLUS_INCLUDE_PATH=/usr/include/gtk-3.0/:/usr/include/pango-1.0/:/usr/include/harfbuzz:/usr/include/cairo/:/usr/include/gdk-pixbuf-2.0/:/usr/include/atk-1.0/
|
||||
|
||||
Web:
|
||||
|
||||
EMCC_CFLAGS="-Wno-missing-field-initializers -Wno-deprecated-literal-operator -fPIC" ./build.sh -c -p webgl -i debug
|
||||
|
||||
EMCC_CFLAGS="-I/Users/nickfisher/Documents/filament/libs/utils/include -I/Users/nickfisher/Documents/filament/libs/image/include -I/Users/nickfisher/Documents/filament/libs/math/include -I../../..//third_party/basisu/encoder/ -I../../..//third_party/libpng/ -I../../..//third_party/tinyexr/ -fPIC" emmake make
|
||||
|
||||
|
||||
## Materials
|
||||
|
||||
We use a single material (no lighting and no transparency) for background images:
|
||||
|
||||
```
|
||||
make generate-background-material
|
||||
```
|
||||
|
||||
# Known issues
|
||||
|
||||
## Windows
|
||||
|
||||
Loading a glTF (but NOT a glb) may crash due to a race condition between uploading resource data to GPU memory and being freed on the host side. This has been fixed in recent versions of Filament, but other bugs on Windows prevent upgrading. Only workaround is to load a .glb file.
|
||||
|
||||
## Android
|
||||
In release mode, you must add the following to your `app/build.gradle`:
|
||||
|
||||
```
|
||||
buildTypes {
|
||||
release {
|
||||
...
|
||||
shrinkResources false
|
||||
minifyEnabled false
|
||||
}
|
||||
}
|
||||
...
|
||||
dependencies {
|
||||
....
|
||||
implementation 'net.java.dev.jna:jna:5.10.0@aar'
|
||||
}
|
||||
```
|
||||
|
||||
# Thanks
|
||||
|
||||
- https://github.com/alexmercerind/flutter-windows-ANGLE-OpenGL-ES
|
||||
3
dart_filament/example_cli/.gitignore
vendored
Normal file
3
dart_filament/example_cli/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
# https://dart.dev/guides/libraries/private-files
|
||||
# Created by `dart pub`
|
||||
.dart_tool/
|
||||
3
dart_filament/example_cli/CHANGELOG.md
Normal file
3
dart_filament/example_cli/CHANGELOG.md
Normal file
@@ -0,0 +1,3 @@
|
||||
## 1.0.0
|
||||
|
||||
- Initial version.
|
||||
2
dart_filament/example_cli/README.md
Normal file
2
dart_filament/example_cli/README.md
Normal file
@@ -0,0 +1,2 @@
|
||||
A sample command-line application with an entrypoint in `bin/`, library code
|
||||
in `lib/`, and example unit test in `test/`.
|
||||
30
dart_filament/example_cli/analysis_options.yaml
Normal file
30
dart_filament/example_cli/analysis_options.yaml
Normal file
@@ -0,0 +1,30 @@
|
||||
# This file configures the static analysis results for your project (errors,
|
||||
# warnings, and lints).
|
||||
#
|
||||
# This enables the 'recommended' set of lints from `package:lints`.
|
||||
# This set helps identify many issues that may lead to problems when running
|
||||
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
|
||||
# style and format.
|
||||
#
|
||||
# If you want a smaller set of lints you can change this to specify
|
||||
# 'package:lints/core.yaml'. These are just the most critical lints
|
||||
# (the recommended set includes the core lints).
|
||||
# The core lints are also what is used by pub.dev for scoring packages.
|
||||
|
||||
include: package:lints/recommended.yaml
|
||||
|
||||
# Uncomment the following section to specify additional rules.
|
||||
|
||||
# linter:
|
||||
# rules:
|
||||
# - camel_case_types
|
||||
|
||||
# analyzer:
|
||||
# exclude:
|
||||
# - path/to/excluded/files/**
|
||||
|
||||
# For more information about the core and recommended set of lints, see
|
||||
# https://dart.dev/go/core-lints
|
||||
|
||||
# For additional information about configuring this file, see
|
||||
# https://dart.dev/guides/language/analysis-options
|
||||
42
dart_filament/example_cli/bin/example_cli.dart
Normal file
42
dart_filament/example_cli/bin/example_cli.dart
Normal file
@@ -0,0 +1,42 @@
|
||||
import 'dart:ffi';
|
||||
import 'dart:io';
|
||||
import 'package:dart_filament/dart_filament/swift/swift_bindings.g.dart';
|
||||
import 'package:dart_filament/dart_filament/utils/dart_resources.dart';
|
||||
import 'package:ffi/ffi.dart';
|
||||
import 'package:dart_filament/dart_filament.dart';
|
||||
import 'package:dart_filament/dart_filament/dart_filament.g.dart';
|
||||
|
||||
void main() async {
|
||||
var testDir = File(Platform.script.toFilePath()).parent.path;
|
||||
final lib = DartFilamentTexture1(DynamicLibrary.open(
|
||||
'../native/lib/macos/swift/libdartfilamenttexture.dylib'));
|
||||
final object = DartFilamentTexture.new1(lib);
|
||||
object.initWithWidth_height_(500, 500);
|
||||
|
||||
final resourceLoader = calloc<ResourceLoaderWrapper>(1);
|
||||
var loadToOut = NativeCallable<
|
||||
Void Function(Pointer<Char>,
|
||||
Pointer<ResourceBuffer>)>.listener(DartResourceLoader.loadResource);
|
||||
|
||||
resourceLoader.ref.loadToOut = loadToOut.nativeFunction;
|
||||
var freeResource = NativeCallable<Void Function(ResourceBuffer)>.listener(
|
||||
DartResourceLoader.freeResource);
|
||||
resourceLoader.ref.freeResource = freeResource.nativeFunction;
|
||||
|
||||
var viewer = FilamentViewer(resourceLoader: resourceLoader);
|
||||
|
||||
await viewer.initialized;
|
||||
await viewer.createSwapChain(500, 500);
|
||||
await viewer.createRenderTarget(500, 500, object.metalTextureAddress);
|
||||
await viewer.updateViewportAndCameraProjection(500, 500);
|
||||
|
||||
var outDir = Directory("$testDir/skybox");
|
||||
outDir.createSync();
|
||||
await viewer.setRecordingOutputDirectory(outDir.path);
|
||||
await viewer.setRecording(true);
|
||||
await viewer.loadSkybox(
|
||||
"file:///$testDir/../../../flutter_filament/example/assets/default_env/default_env_skybox.ktx");
|
||||
await Future.delayed(Duration(milliseconds: 16));
|
||||
await viewer.render();
|
||||
await viewer.dispose();
|
||||
}
|
||||
BIN
dart_filament/example_cli/bin/output_000000.png
Normal file
BIN
dart_filament/example_cli/bin/output_000000.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
BIN
dart_filament/example_cli/bin/skybox/output_000008.png
Normal file
BIN
dart_filament/example_cli/bin/skybox/output_000008.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 46 KiB |
484
dart_filament/example_cli/pubspec.lock
Normal file
484
dart_filament/example_cli/pubspec.lock
Normal file
@@ -0,0 +1,484 @@
|
||||
# Generated by pub
|
||||
# See https://dart.dev/tools/pub/glossary#lockfile
|
||||
packages:
|
||||
_fe_analyzer_shared:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: _fe_analyzer_shared
|
||||
sha256: "0b2f2bd91ba804e53a61d757b986f89f1f9eaed5b11e4b2f5a2468d86d6c9fc7"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "67.0.0"
|
||||
analyzer:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: analyzer
|
||||
sha256: "37577842a27e4338429a1cbc32679d508836510b056f1eedf0c8d20e39c1383d"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.4.1"
|
||||
animation_tools_dart:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: animation_tools_dart
|
||||
sha256: c4bc4096d43227b573345a3ea3cb26c3af47a70af31cd7d7d3a5b7c99e33d615
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.0.2"
|
||||
args:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: args
|
||||
sha256: "7cf60b9f0cc88203c5a190b4cd62a99feea42759a7fa695010eb5de1c0b2252a"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.5.0"
|
||||
async:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: async
|
||||
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.11.0"
|
||||
boolean_selector:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: boolean_selector
|
||||
sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
cli_config:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: cli_config
|
||||
sha256: ac20a183a07002b700f0c25e61b7ee46b23c309d76ab7b7640a028f18e4d99ec
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.2.0"
|
||||
cli_util:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: cli_util
|
||||
sha256: c05b7406fdabc7a49a3929d4af76bcaccbbffcbcdcf185b082e1ae07da323d19
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.4.1"
|
||||
collection:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: collection
|
||||
sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.18.0"
|
||||
convert:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: convert
|
||||
sha256: "0f08b14755d163f6e2134cb58222dd25ea2a2ee8a195e53983d57c075324d592"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.1"
|
||||
coverage:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: coverage
|
||||
sha256: "8acabb8306b57a409bf4c83522065672ee13179297a6bb0cb9ead73948df7c76"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.7.2"
|
||||
crypto:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: crypto
|
||||
sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.3"
|
||||
dart_filament:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
path: ".."
|
||||
relative: true
|
||||
source: path
|
||||
version: "0.5.0"
|
||||
ffi:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: ffi
|
||||
sha256: "493f37e7df1804778ff3a53bd691d8692ddf69702cf4c1c1096a2e41b4779e21"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
ffigen:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: ffigen
|
||||
sha256: dead012f29db2be71ea152458f5eab600de98fbc244e01088ae6bf2616bceca7
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "11.0.0"
|
||||
file:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: file
|
||||
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "7.0.0"
|
||||
frontend_server_client:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: frontend_server_client
|
||||
sha256: f64a0333a82f30b0cca061bc3d143813a486dc086b574bfb233b7c1372427694
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.0.0"
|
||||
glob:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: glob
|
||||
sha256: "0e7014b3b7d4dac1ca4d6114f82bf1782ee86745b9b42a92c9289c23d8a0ab63"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
http_multi_server:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: http_multi_server
|
||||
sha256: "97486f20f9c2f7be8f514851703d0119c3596d14ea63227af6f7a481ef2b2f8b"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.2.1"
|
||||
http_parser:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: http_parser
|
||||
sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "4.0.2"
|
||||
io:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: io
|
||||
sha256: "2ec25704aba361659e10e3e5f5d672068d332fc8ac516421d483a11e5cbd061e"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.4"
|
||||
js:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: js
|
||||
sha256: c1b2e9b5ea78c45e1a0788d29606ba27dc5f71f019f32ca5140f61ef071838cf
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.7.1"
|
||||
lints:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: lints
|
||||
sha256: cbf8d4b858bb0134ef3ef87841abdf8d63bfc255c266b7bf6b39daa1085c4290
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.0"
|
||||
logging:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: logging
|
||||
sha256: "623a88c9594aa774443aa3eb2d41807a48486b5613e67599fb4c41c0ad47c340"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
matcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: matcher
|
||||
sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.12.16+1"
|
||||
meta:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: meta
|
||||
sha256: "25dfcaf170a0190f47ca6355bdd4552cb8924b430512ff0cafb8db9bd41fe33b"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.14.0"
|
||||
mime:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: mime
|
||||
sha256: "2e123074287cc9fd6c09de8336dae606d1ddb88d9ac47358826db698c176a1f2"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.5"
|
||||
native_assets_cli:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: native_assets_cli
|
||||
sha256: "9c1b67ccf85ec9282f34e5348ae78dcb7da2c7dc965c0265306477d977853a0d"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.5.4"
|
||||
native_toolchain_c:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: native_toolchain_c
|
||||
sha256: "1b1b86f47570378d0003f0d949fbb03b637ec9d2dcbcf698a16f7cbffb3a945c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.4.1"
|
||||
node_preamble:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: node_preamble
|
||||
sha256: "6e7eac89047ab8a8d26cf16127b5ed26de65209847630400f9aefd7cd5c730db"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.2"
|
||||
package_config:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: package_config
|
||||
sha256: "1c5b77ccc91e4823a5af61ee74e6b972db1ef98c2ff5a18d3161c982a55448bd"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.0"
|
||||
path:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: path
|
||||
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.9.0"
|
||||
plugin_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: plugin_platform_interface
|
||||
sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.8"
|
||||
pool:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pool
|
||||
sha256: "20fe868b6314b322ea036ba325e6fc0711a22948856475e2c2b6306e8ab39c2a"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.5.1"
|
||||
pub_semver:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: pub_semver
|
||||
sha256: "40d3ab1bbd474c4c2328c91e3a7df8c6dd629b79ece4c4bd04bee496a224fb0c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.4"
|
||||
quiver:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: quiver
|
||||
sha256: b1c1ac5ce6688d77f65f3375a9abb9319b3cb32486bdc7a1e0fdf004d7ba4e47
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.2.1"
|
||||
shelf:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shelf
|
||||
sha256: ad29c505aee705f41a4d8963641f91ac4cee3c8fad5947e033390a7bd8180fa4
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.4.1"
|
||||
shelf_packages_handler:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shelf_packages_handler
|
||||
sha256: "89f967eca29607c933ba9571d838be31d67f53f6e4ee15147d5dc2934fee1b1e"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.0.2"
|
||||
shelf_static:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shelf_static
|
||||
sha256: a41d3f53c4adf0f57480578c1d61d90342cd617de7fc8077b1304643c2d85c1e
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.2"
|
||||
shelf_web_socket:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: shelf_web_socket
|
||||
sha256: "9ca081be41c60190ebcb4766b2486a7d50261db7bd0f5d9615f2d653637a84c1"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.0.4"
|
||||
source_map_stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: source_map_stack_trace
|
||||
sha256: "84cf769ad83aa6bb61e0aa5a18e53aea683395f196a6f39c4c881fb90ed4f7ae"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.1"
|
||||
source_maps:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: source_maps
|
||||
sha256: "708b3f6b97248e5781f493b765c3337db11c5d2c81c3094f10904bfa8004c703"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.10.12"
|
||||
source_span:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: source_span
|
||||
sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.10.0"
|
||||
stack_trace:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stack_trace
|
||||
sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.11.1"
|
||||
stream_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: stream_channel
|
||||
sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
string_scanner:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: string_scanner
|
||||
sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.0"
|
||||
term_glyph:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: term_glyph
|
||||
sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.1"
|
||||
test:
|
||||
dependency: "direct dev"
|
||||
description:
|
||||
name: test
|
||||
sha256: d72b538180efcf8413cd2e4e6fcc7ae99c7712e0909eb9223f9da6e6d0ef715f
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.25.4"
|
||||
test_api:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_api
|
||||
sha256: "2419f20b0c8677b2d67c8ac4d1ac7372d862dc6c460cdbb052b40155408cd794"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.7.1"
|
||||
test_core:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: test_core
|
||||
sha256: "4d070a6bc36c1c4e89f20d353bfd71dc30cdf2bd0e14349090af360a029ab292"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.6.2"
|
||||
tuple:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: tuple
|
||||
sha256: a97ce2013f240b2f3807bcbaf218765b6f301c3eff91092bcfa23a039e7dd151
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.2"
|
||||
typed_data:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: typed_data
|
||||
sha256: facc8d6582f16042dd49f2463ff1bd6e2c9ef9f3d5da3d9b087e244a7b564b3c
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.3.2"
|
||||
vector_math:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vector_math
|
||||
sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.4"
|
||||
vm_service:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: vm_service
|
||||
sha256: "3923c89304b715fb1eb6423f017651664a03bf5f4b29983627c4da791f74a4ec"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "14.2.1"
|
||||
watcher:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: watcher
|
||||
sha256: "3d2ad6751b3c16cf07c7fca317a1413b3f26530319181b37e3b9039b84fc01d8"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.1.0"
|
||||
web:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: web
|
||||
sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "0.5.1"
|
||||
web_socket_channel:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: web_socket_channel
|
||||
sha256: "58c6666b342a38816b2e7e50ed0f1e261959630becd4c879c4f26bfa14aa5a42"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.4.5"
|
||||
webkit_inspection_protocol:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: webkit_inspection_protocol
|
||||
sha256: "87d3f2333bb240704cd3f1c6b5b7acd8a10e7f0bc28c28dcf14e782014f4a572"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "1.2.1"
|
||||
yaml:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: yaml
|
||||
sha256: "75769501ea3489fca56601ff33454fe45507ea3bfb014161abc3b43ae25989d5"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "3.1.2"
|
||||
yaml_edit:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: yaml_edit
|
||||
sha256: c566f4f804215d84a7a2c377667f546c6033d5b34b4f9e60dfb09d17c4e97826
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.2.0"
|
||||
sdks:
|
||||
dart: ">=3.5.0-76.0.dev <4.0.0"
|
||||
20
dart_filament/example_cli/pubspec.yaml
Normal file
20
dart_filament/example_cli/pubspec.yaml
Normal file
@@ -0,0 +1,20 @@
|
||||
name: example_cli
|
||||
description: A sample command-line application.
|
||||
version: 1.0.0
|
||||
# repository: https://github.com/my_org/my_repo
|
||||
|
||||
environment:
|
||||
sdk: ^3.5.0-76.0.dev
|
||||
|
||||
# Add regular dependencies here.
|
||||
dependencies:
|
||||
dart_filament:
|
||||
path: ../
|
||||
ffi:
|
||||
|
||||
dev_dependencies:
|
||||
ffigen: ^11.0.0
|
||||
lints: ^3.0.0
|
||||
test: ^1.24.0
|
||||
native_assets_cli: ^0.5.0
|
||||
native_toolchain_c: ^0.4.0
|
||||
8
dart_filament/example_cli/test/example_cli_test.dart
Normal file
8
dart_filament/example_cli/test/example_cli_test.dart
Normal file
@@ -0,0 +1,8 @@
|
||||
import 'package:example_cli/example_cli.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
void main() {
|
||||
test('calculate', () {
|
||||
expect(calculate(), 42);
|
||||
});
|
||||
}
|
||||
93
dart_filament/hook/build.dart
Normal file
93
dart_filament/hook/build.dart
Normal file
@@ -0,0 +1,93 @@
|
||||
// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:native_assets_cli/native_assets_cli.dart';
|
||||
import 'package:native_toolchain_c/native_toolchain_c.dart';
|
||||
|
||||
void main(List<String> args) async {
|
||||
await build(args, (config, output) async {
|
||||
var platform = config.targetOS.toString().toLowerCase();
|
||||
var libDir = "${config.packageRoot.toFilePath()}/native/lib/$platform/";
|
||||
|
||||
final packageName = config.packageName;
|
||||
|
||||
final sources = Directory("${config.packageRoot.toFilePath()}/native/src")
|
||||
.listSync(recursive: true)
|
||||
.whereType<File>()
|
||||
.map((f) => f.path)
|
||||
.toList();
|
||||
sources.addAll([
|
||||
"${config.packageRoot.toFilePath()}/native/include/material/gizmo.c",
|
||||
"${config.packageRoot.toFilePath()}/native/include/material/image.c",
|
||||
]);
|
||||
|
||||
final cbuilder = CBuilder.library(
|
||||
name: packageName,
|
||||
language: Language.cpp,
|
||||
assetName: 'dart_filament.dart',
|
||||
sources: sources,
|
||||
includes: ['native/include', 'native/include/filament'],
|
||||
flags: [
|
||||
'-mmacosx-version-min=13.0',
|
||||
'-std=c++17',
|
||||
'-framework',
|
||||
'Foundation',
|
||||
'-framework',
|
||||
'CoreVideo',
|
||||
'-framework',
|
||||
'Cocoa',
|
||||
'-framework',
|
||||
'Metal',
|
||||
"-lfilament",
|
||||
"-lbackend",
|
||||
"-lfilameshio",
|
||||
"-lviewer",
|
||||
"-lfilamat",
|
||||
"-lgeometry",
|
||||
"-lutils",
|
||||
"-lfilabridge",
|
||||
"-lgltfio_core",
|
||||
"-lfilament-iblprefilter",
|
||||
"-limage",
|
||||
"-limageio",
|
||||
"-ltinyexr",
|
||||
"-lgltfio_core",
|
||||
"-lfilaflat",
|
||||
"-ldracodec",
|
||||
"-libl",
|
||||
"-lktxreader",
|
||||
"-lpng",
|
||||
"-lz",
|
||||
"-lstb",
|
||||
"-luberzlib",
|
||||
"-lsmol-v",
|
||||
"-luberarchive",
|
||||
"-lzstd",
|
||||
"-lstdc++",
|
||||
"-lbluegl",
|
||||
"-lbluevk",
|
||||
"-lbasis_transcoder",
|
||||
"-L$libDir",
|
||||
"-force_load",
|
||||
"$libDir/libbackend.a",
|
||||
"-force_load",
|
||||
"$libDir/libktxreader.a",
|
||||
"-force_load",
|
||||
"$libDir/libvkshaders.a",
|
||||
],
|
||||
dartBuildFiles: ['hook/build.dart'],
|
||||
);
|
||||
|
||||
await cbuilder.run(
|
||||
buildConfig: config,
|
||||
buildOutput: output,
|
||||
logger: Logger('')
|
||||
..level = Level.ALL
|
||||
..onRecord.listen((record) => print(record.message)),
|
||||
);
|
||||
});
|
||||
}
|
||||
7
dart_filament/lib/dart_filament.dart
Normal file
7
dart_filament/lib/dart_filament.dart
Normal file
@@ -0,0 +1,7 @@
|
||||
library filament_dart;
|
||||
|
||||
export 'dart_filament/abstract_filament_viewer.dart';
|
||||
export 'dart_filament/filament_viewer_impl.dart';
|
||||
export 'dart_filament/dart_filament.g.dart';
|
||||
|
||||
export 'dart_filament/entities/entity_transform_controller.dart';
|
||||
@@ -1,18 +1,12 @@
|
||||
// ignore_for_file: constant_identifier_names
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:typed_data';
|
||||
import 'dart:ui' as ui;
|
||||
import 'dart:ffi';
|
||||
import 'package:animation_tools_dart/animation_tools_dart.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:dart_filament/dart_filament/entities/filament_entity.dart';
|
||||
import 'package:dart_filament/dart_filament/entities/gizmo.dart';
|
||||
|
||||
import 'package:flutter_filament/filament/entities/gizmo.dart';
|
||||
import 'package:vector_math/vector_math_64.dart';
|
||||
|
||||
import 'package:animation_tools_dart/animation_tools_dart.dart';
|
||||
|
||||
// a handle that can be safely passed back to the rendering layer to manipulate an Entity
|
||||
typedef FilamentEntity = int;
|
||||
typedef RenderCallback = Pointer<NativeFunction<Void Function(Pointer<Void>)>>;
|
||||
|
||||
// "picking" means clicking/tapping on the viewport, and unprojecting the X/Y coordinate to determine whether any renderable entities were present at those coordinates.
|
||||
typedef FilamentPickResult = ({FilamentEntity entity, double x, double y});
|
||||
@@ -44,27 +38,7 @@ class TextureDetails {
|
||||
{required this.textureId, required this.width, required this.height});
|
||||
}
|
||||
|
||||
abstract class FilamentController {
|
||||
///
|
||||
/// A [ValueNotifier] to indicate whether a FilamentViewer is currently available.
|
||||
/// (FilamentViewer is a C++ type, hence why it is not referenced) here.
|
||||
/// Call [createViewer]/[destroyViewer] to create/destroy a FilamentViewer.
|
||||
///
|
||||
ValueNotifier<bool> get hasViewer;
|
||||
|
||||
///
|
||||
/// Whether a Flutter Texture widget should be inserted into the widget hierarchy.
|
||||
/// This will be false on certain platforms where we use a transparent window underlay.
|
||||
/// Used internally by [FilamentWidget]; you probably don't need to access this property directly.
|
||||
///
|
||||
bool get requiresTextureWidget;
|
||||
|
||||
///
|
||||
/// The Flutter texture ID and dimensions for current texture in use.
|
||||
/// This is only used by [FilamentWidget]; you shouldn't need to access directly yourself.
|
||||
///
|
||||
final textureDetails = ValueNotifier<TextureDetails?>(null);
|
||||
|
||||
abstract class AbstractFilamentViewer {
|
||||
///
|
||||
/// The result(s) of calling [pick] (see below).
|
||||
/// This may be a broadcast stream, so you should ensure you have subscribed to this stream before calling [pick].
|
||||
@@ -93,41 +67,9 @@ abstract class FilamentController {
|
||||
Future setFrameRate(int framerate);
|
||||
|
||||
///
|
||||
/// Destroys the viewer and all backing textures. You can leave the FilamentWidget in the hierarchy after this is called, but you will need to manually call [createViewer] to
|
||||
/// Destroys/disposes the viewer (including the entire scene). You cannot use the viewer after calling this method.
|
||||
///
|
||||
Future destroy();
|
||||
|
||||
///
|
||||
/// Destroys the viewer only, leaving the texture intact. You probably want to call [destroy] instead of this; [destroyViewer] is exposed mostly for lifecycle changes which are handled by FilamentWidget.
|
||||
///
|
||||
Future destroyViewer();
|
||||
|
||||
///
|
||||
/// Destroys the specified backing texture. You probably want to call [destroy] instead of this; this is exposed mostly for lifecycle changes which are handled by FilamentWidget.
|
||||
///
|
||||
Future destroyTexture();
|
||||
|
||||
///
|
||||
/// Create a FilamentViewer. Must be called at least one frame after a [FilamentWidget] has been inserted into the rendering hierarchy.
|
||||
///
|
||||
/// Before a FilamentViewer is created, the FilamentWidget will only contain an empty Container (by default, with a solid red background).
|
||||
/// FilamentWidget will then call [setDimensions] with dimensions/pixel ratio of the viewport
|
||||
/// Calling [createViewer] will then dispatch a request to the native platform to create a hardware texture (Metal on iOS, OpenGL on Linux, GLES on Android and Windows) and a FilamentViewer (the main interface for manipulating the 3D scene) .
|
||||
/// [FilamentWidget] will be notified that a texture is available and will replace the empty Container with a Texture widget
|
||||
///
|
||||
Future createViewer();
|
||||
|
||||
///
|
||||
/// Sets the dimensions of the viewport and pixel ratio (obtained from [MediaQuery]) to be used the next time [resize] or [createViewer] is called.
|
||||
/// This is called by FilamentWidget; you shouldn't need to invoke this manually.
|
||||
///
|
||||
Future setDimensions(ui.Rect rect, double pixelRatio);
|
||||
|
||||
///
|
||||
/// Resize the viewport & backing texture to the current dimensions (as last set by [setDimensions]).
|
||||
/// This is called by FilamentWidget; you shouldn't need to invoke this manually.
|
||||
///
|
||||
Future resize();
|
||||
Future dispose();
|
||||
|
||||
///
|
||||
/// Set the background image to [path] (which should have a file extension .png, .jpg, or .ktx).
|
||||
@@ -151,7 +93,7 @@ abstract class FilamentController {
|
||||
///
|
||||
/// Sets the color for the background plane (positioned at the maximum depth, i.e. behind all other objects including the skybox).
|
||||
///
|
||||
Future setBackgroundColor(Color color);
|
||||
Future setBackgroundColor(double r, double g, double b, double alpha);
|
||||
|
||||
///
|
||||
/// Load a skybox from [skyboxPath] (which must be a .ktx file)
|
||||
@@ -380,7 +322,7 @@ abstract class FilamentController {
|
||||
///
|
||||
/// Sets the current scene camera to the glTF camera under [name] in [entity].
|
||||
///
|
||||
Future setCameraFov(double degrees);
|
||||
Future setCameraFov(double degrees, double width, double height);
|
||||
|
||||
///
|
||||
/// Sets the tone mapping (requires postprocessing).
|
||||
@@ -487,8 +429,8 @@ abstract class FilamentController {
|
||||
///
|
||||
/// Sets the `baseColorFactor` property for the material at index [materialIndex] in [entity] under node [meshName] to [color].
|
||||
///
|
||||
Future setMaterialColor(
|
||||
FilamentEntity entity, String meshName, int materialIndex, Color color);
|
||||
Future setMaterialColor(FilamentEntity entity, String meshName,
|
||||
int materialIndex, double r, double g, double b, double a);
|
||||
|
||||
///
|
||||
/// Scale [entity] to fit within the unit cube.
|
||||
@@ -703,5 +645,5 @@ abstract class Scene {
|
||||
///
|
||||
/// The transform gizmo.
|
||||
///
|
||||
Gizmo get gizmo;
|
||||
Future<Gizmo> get gizmo;
|
||||
}
|
||||
1705
dart_filament/lib/dart_filament/dart_filament.g.dart
Normal file
1705
dart_filament/lib/dart_filament/dart_filament.g.dart
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,182 @@
|
||||
import 'dart:async';
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:dart_filament/dart_filament/entities/filament_entity.dart';
|
||||
import 'package:dart_filament/dart_filament/abstract_filament_viewer.dart';
|
||||
import 'package:dart_filament/dart_filament/filament_viewer_impl.dart';
|
||||
import 'package:vector_math/vector_math_64.dart' as v;
|
||||
|
||||
class EntityTransformController {
|
||||
final FilamentViewer controller;
|
||||
final FilamentEntity _entity;
|
||||
|
||||
late Timer _ticker;
|
||||
|
||||
double translationSpeed;
|
||||
double rotationRadsPerSecond;
|
||||
|
||||
bool _forward = false;
|
||||
bool _strafeLeft = false;
|
||||
bool _strafeRight = false;
|
||||
bool _back = false;
|
||||
bool _rotateLeft = false;
|
||||
bool _rotateRight = false;
|
||||
double _rotY = 0;
|
||||
|
||||
int? forwardAnimationIndex;
|
||||
int? backwardAnimationIndex;
|
||||
int? strafeLeftAnimationIndex;
|
||||
int? strafeRightAnimationIndex;
|
||||
|
||||
EntityTransformController(this.controller, this._entity,
|
||||
{this.translationSpeed = 1,
|
||||
this.rotationRadsPerSecond = pi / 2,
|
||||
this.forwardAnimationIndex,
|
||||
this.backwardAnimationIndex,
|
||||
this.strafeLeftAnimationIndex,
|
||||
this.strafeRightAnimationIndex}) {
|
||||
var translationSpeedPerTick = translationSpeed / (1000 / 16.667);
|
||||
var rotationRadsPerTick = rotationRadsPerSecond / (1000 / 16.667);
|
||||
_ticker = Timer.periodic(const Duration(milliseconds: 16), (timer) {
|
||||
_update(translationSpeedPerTick, rotationRadsPerTick);
|
||||
});
|
||||
}
|
||||
|
||||
bool _enabled = true;
|
||||
void enable() {
|
||||
_enabled = true;
|
||||
}
|
||||
|
||||
void disable() {
|
||||
_enabled = false;
|
||||
}
|
||||
|
||||
void _update(
|
||||
double translationSpeedPerTick, double rotationRadsPerTick) async {
|
||||
if (!_enabled) {
|
||||
return;
|
||||
}
|
||||
var _position = v.Vector3.zero();
|
||||
bool updateTranslation = false;
|
||||
if (_forward) {
|
||||
_position.add(v.Vector3(0, 0, -translationSpeedPerTick));
|
||||
updateTranslation = true;
|
||||
}
|
||||
if (_back) {
|
||||
_position.add(v.Vector3(0, 0, translationSpeedPerTick));
|
||||
updateTranslation = true;
|
||||
}
|
||||
if (_strafeLeft) {
|
||||
_position.add(v.Vector3(-translationSpeedPerTick, 0, 0));
|
||||
updateTranslation = true;
|
||||
}
|
||||
if (_strafeRight) {
|
||||
_position.add(v.Vector3(translationSpeedPerTick, 0, 0));
|
||||
updateTranslation = true;
|
||||
}
|
||||
|
||||
// TODO - use pitch/yaw/roll
|
||||
bool updateRotation = false;
|
||||
var _rotation = v.Quaternion.identity();
|
||||
|
||||
double rads = 0.0;
|
||||
if (_rotY != 0) {
|
||||
rads = _rotY * pi / 1000;
|
||||
var rotY = v.Quaternion.axisAngle(v.Vector3(0, 1, 0), rads).normalized();
|
||||
_rotation = rotY;
|
||||
updateRotation = true;
|
||||
_rotY = 0;
|
||||
}
|
||||
|
||||
if (updateTranslation) {
|
||||
await controller.queuePositionUpdate(
|
||||
_entity, _position.x, _position.y, _position.z,
|
||||
relative: true);
|
||||
}
|
||||
if (updateRotation) {
|
||||
await controller.queueRotationUpdateQuat(_entity, _rotation,
|
||||
relative: true);
|
||||
}
|
||||
}
|
||||
|
||||
void look(double deltaX) async {
|
||||
_rotY -= deltaX;
|
||||
}
|
||||
|
||||
void dispose() {
|
||||
_ticker.cancel();
|
||||
}
|
||||
|
||||
bool _playingForwardAnimation = false;
|
||||
bool _playingBackwardAnimation = false;
|
||||
|
||||
void forwardPressed() async {
|
||||
_forward = true;
|
||||
if (forwardAnimationIndex != null && !_playingForwardAnimation) {
|
||||
await controller.playAnimation(_entity, forwardAnimationIndex!,
|
||||
loop: true, replaceActive: false);
|
||||
_playingForwardAnimation = true;
|
||||
}
|
||||
}
|
||||
|
||||
void forwardReleased() async {
|
||||
_forward = false;
|
||||
await Future.delayed(Duration(milliseconds: 50));
|
||||
if (!_forward) {
|
||||
_playingForwardAnimation = false;
|
||||
if (forwardAnimationIndex != null) {
|
||||
await controller.stopAnimation(_entity, forwardAnimationIndex!);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void backPressed() async {
|
||||
_back = true;
|
||||
if (forwardAnimationIndex != null) {
|
||||
if (!_playingBackwardAnimation) {
|
||||
await controller.playAnimation(_entity, forwardAnimationIndex!,
|
||||
loop: true, replaceActive: false, reverse: true);
|
||||
_playingBackwardAnimation = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void backReleased() async {
|
||||
_back = false;
|
||||
if (forwardAnimationIndex != null) {
|
||||
await controller.stopAnimation(_entity, forwardAnimationIndex!);
|
||||
}
|
||||
_playingBackwardAnimation = false;
|
||||
}
|
||||
|
||||
void strafeLeftPressed() {
|
||||
_strafeLeft = true;
|
||||
}
|
||||
|
||||
void strafeLeftReleased() async {
|
||||
_strafeLeft = false;
|
||||
}
|
||||
|
||||
void strafeRightPressed() {
|
||||
_strafeRight = true;
|
||||
}
|
||||
|
||||
void strafeRightReleased() async {
|
||||
_strafeRight = false;
|
||||
}
|
||||
|
||||
void Function()? _mouse1DownCallback;
|
||||
void onMouse1Down(void Function() callback) {
|
||||
_mouse1DownCallback = callback;
|
||||
}
|
||||
|
||||
void mouse1Down() async {
|
||||
_mouse1DownCallback?.call();
|
||||
}
|
||||
|
||||
void mouse1Up() async {}
|
||||
|
||||
void mouse2Up() async {}
|
||||
|
||||
void mouse2Down() async {}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
// a handle that can be safely passed back to the rendering layer to manipulate an Entity
|
||||
typedef FilamentEntity = int;
|
||||
@@ -1,8 +1,8 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:dart_filament/dart_filament/entities/filament_entity.dart';
|
||||
import 'package:dart_filament/dart_filament/filament_viewer_impl.dart';
|
||||
import 'package:vector_math/vector_math_64.dart';
|
||||
|
||||
import '../filament_controller.dart';
|
||||
import '../abstract_filament_viewer.dart';
|
||||
|
||||
class Gizmo {
|
||||
final FilamentEntity x;
|
||||
@@ -12,7 +12,7 @@ class Gizmo {
|
||||
final FilamentEntity z;
|
||||
Vector3 _z = Vector3(0.0, 0.0, 0.1);
|
||||
|
||||
final FilamentController controller;
|
||||
final FilamentViewer controller;
|
||||
|
||||
FilamentEntity? _activeAxis;
|
||||
FilamentEntity? _activeEntity;
|
||||
@@ -28,7 +28,7 @@ class Gizmo {
|
||||
await controller.reveal(z, null);
|
||||
}
|
||||
|
||||
void translate(Offset offset) async {
|
||||
void translate(double x, double y) async {
|
||||
late Vector3 vec;
|
||||
if (_activeAxis == x) {
|
||||
vec = _x;
|
||||
@@ -37,8 +37,8 @@ class Gizmo {
|
||||
} else if (_activeAxis == z) {
|
||||
vec = _z;
|
||||
}
|
||||
await controller.queuePositionUpdate(_activeEntity!, offset.dx * vec.x,
|
||||
-offset.dy * vec.y, -offset.dx * vec.z,
|
||||
await controller.queuePositionUpdate(
|
||||
_activeEntity!, x * vec.x, -y * vec.y, -x * vec.z,
|
||||
relative: true);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,6 @@ class Gizmo {
|
||||
}
|
||||
|
||||
void attach(FilamentEntity entity) async {
|
||||
print("Attaching to $entity");
|
||||
_activeAxis = null;
|
||||
_activeEntity = entity;
|
||||
await _reveal();
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,17 +1,33 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter_filament/filament/entities/gizmo.dart';
|
||||
import 'package:flutter_filament/filament/filament_controller.dart';
|
||||
import 'dart:ffi';
|
||||
import 'package:dart_filament/dart_filament/dart_filament.g.dart';
|
||||
import 'package:dart_filament/dart_filament/entities/filament_entity.dart';
|
||||
import 'package:dart_filament/dart_filament/filament_viewer_impl.dart';
|
||||
import 'package:ffi/ffi.dart';
|
||||
|
||||
import 'entities/gizmo.dart';
|
||||
import 'abstract_filament_viewer.dart';
|
||||
|
||||
///
|
||||
/// For now, this class just holds the entities that have been loaded (though not necessarily visible in the Filament Scene).
|
||||
///
|
||||
class SceneImpl extends Scene {
|
||||
final Gizmo _gizmo;
|
||||
Gizmo get gizmo => _gizmo;
|
||||
Gizmo? _gizmo;
|
||||
Future<Gizmo> get gizmo async {
|
||||
if (_gizmo == null) {
|
||||
final out = calloc<Int32>(3);
|
||||
get_gizmo(_sceneManager!, out);
|
||||
_gizmo = Gizmo(out[0], out[1], out[2], controller);
|
||||
calloc.free(out);
|
||||
}
|
||||
return _gizmo!;
|
||||
}
|
||||
|
||||
FilamentController controller;
|
||||
FilamentViewer controller;
|
||||
|
||||
SceneImpl(this._gizmo, this.controller);
|
||||
final Pointer<Void> _sceneManager;
|
||||
|
||||
SceneImpl(this._gizmo, this.controller, this._sceneManager);
|
||||
|
||||
@override
|
||||
FilamentEntity? selected;
|
||||
@@ -41,7 +57,7 @@ class SceneImpl extends Scene {
|
||||
var children = await controller.getChildEntities(entity, true);
|
||||
if (selected == entity || children.contains(selected)) {
|
||||
selected = null;
|
||||
_gizmo.detach();
|
||||
_gizmo?.detach();
|
||||
}
|
||||
_lights.remove(entity);
|
||||
_onUnloadController.add(entity);
|
||||
@@ -52,7 +68,7 @@ class SceneImpl extends Scene {
|
||||
var children = await controller.getChildEntities(entity, true);
|
||||
if (selected == entity || children.contains(selected)) {
|
||||
selected = null;
|
||||
_gizmo.detach();
|
||||
_gizmo?.detach();
|
||||
}
|
||||
_entities.remove(entity);
|
||||
_onUnloadController.add(entity);
|
||||
@@ -70,7 +86,7 @@ class SceneImpl extends Scene {
|
||||
for (final light in _lights) {
|
||||
if (selected == light) {
|
||||
selected = null;
|
||||
_gizmo.detach();
|
||||
_gizmo?.detach();
|
||||
}
|
||||
_onUnloadController.add(light);
|
||||
}
|
||||
@@ -83,7 +99,7 @@ class SceneImpl extends Scene {
|
||||
for (final entity in _entities) {
|
||||
if (selected == entity) {
|
||||
selected = null;
|
||||
_gizmo.detach();
|
||||
_gizmo?.detach();
|
||||
}
|
||||
_onUnloadController.add(entity);
|
||||
}
|
||||
@@ -116,7 +132,7 @@ class SceneImpl extends Scene {
|
||||
@override
|
||||
void select(FilamentEntity entity) {
|
||||
selected = entity;
|
||||
_gizmo.attach(entity);
|
||||
_gizmo?.attach(entity);
|
||||
_onUpdatedController.add(true);
|
||||
}
|
||||
}
|
||||
73832
dart_filament/lib/dart_filament/swift/swift_bindings.g.dart
Normal file
73832
dart_filament/lib/dart_filament/swift/swift_bindings.g.dart
Normal file
File diff suppressed because it is too large
Load Diff
29
dart_filament/lib/dart_filament/utils/dart_resources.dart
Normal file
29
dart_filament/lib/dart_filament/utils/dart_resources.dart
Normal file
@@ -0,0 +1,29 @@
|
||||
import 'dart:ffi';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:dart_filament/dart_filament/dart_filament.g.dart';
|
||||
import 'package:ffi/ffi.dart';
|
||||
|
||||
class DartResourceLoader {
|
||||
static final _assets = <int, Pointer>{};
|
||||
static void loadResource(Pointer<Char> uri, Pointer<ResourceBuffer> out) {
|
||||
try {
|
||||
var data = File(uri.cast<Utf8>().toDartString().replaceAll("file://", ""))
|
||||
.readAsBytesSync();
|
||||
var ptr = calloc<Uint8>(data.lengthInBytes);
|
||||
ptr.asTypedList(data.lengthInBytes).setRange(0, data.lengthInBytes, data);
|
||||
|
||||
out.ref.data = ptr.cast<Void>();
|
||||
out.ref.size = data.lengthInBytes;
|
||||
out.ref.id = _assets.length;
|
||||
_assets[out.ref.id] = ptr;
|
||||
} catch (err) {
|
||||
print(err);
|
||||
out.ref.size = -1;
|
||||
}
|
||||
}
|
||||
|
||||
static void freeResource(ResourceBuffer rb) {
|
||||
calloc.free(_assets[rb.id]!);
|
||||
}
|
||||
}
|
||||
@@ -56,7 +56,6 @@ extern "C"
|
||||
|
||||
FLUTTER_PLUGIN_EXPORT const void *create_filament_viewer(const void *const context, const ResourceLoaderWrapper *const loader, void *const platform, const char *uberArchivePath);
|
||||
FLUTTER_PLUGIN_EXPORT void destroy_filament_viewer(const void *const viewer);
|
||||
FLUTTER_PLUGIN_EXPORT ResourceLoaderWrapper *make_resource_loader(LoadFilamentResourceFromOwner loadFn, FreeFilamentResourceFromOwner freeFn, void *owner);
|
||||
FLUTTER_PLUGIN_EXPORT void *get_scene_manager(const void *const viewer);
|
||||
FLUTTER_PLUGIN_EXPORT void create_render_target(const void *const viewer, intptr_t texture, uint32_t width, uint32_t height);
|
||||
FLUTTER_PLUGIN_EXPORT void clear_background_image(const void *const viewer);
|
||||
@@ -1,7 +1,7 @@
|
||||
#ifndef _FLUTTER_FILAMENT_FFI_API_H
|
||||
#define _FLUTTER_FILAMENT_FFI_API_H
|
||||
|
||||
#include "FlutterFilamentApi.h"
|
||||
#include "DartFilamentApi.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
@@ -39,7 +39,7 @@ extern "C"
|
||||
FLUTTER_PLUGIN_EXPORT void set_background_image_position_ffi(void *const viewer, float x, float y, bool clamp);
|
||||
FLUTTER_PLUGIN_EXPORT void set_tone_mapping_ffi(void *const viewer, int toneMapping);
|
||||
FLUTTER_PLUGIN_EXPORT void set_bloom_ffi(void *const viewer, float strength);
|
||||
FLUTTER_PLUGIN_EXPORT void load_skybox_ffi(void *const viewer, const char *skyboxPath);
|
||||
FLUTTER_PLUGIN_EXPORT void load_skybox_ffi(void *const viewer, const char *skyboxPath, void (*onComplete)());
|
||||
FLUTTER_PLUGIN_EXPORT void load_ibl_ffi(void *const viewer, const char *iblPath, float intensity);
|
||||
FLUTTER_PLUGIN_EXPORT void remove_skybox_ffi(void *const viewer);
|
||||
FLUTTER_PLUGIN_EXPORT void remove_ibl_ffi(void *const viewer);
|
||||
@@ -32,13 +32,14 @@
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
|
||||
#include "ResourceBuffer.hpp"
|
||||
#include "SceneManager.hpp"
|
||||
#include "ThreadPool.hpp"
|
||||
|
||||
namespace flutter_filament
|
||||
{
|
||||
|
||||
typedef std::chrono::time_point<std::chrono::high_resolution_clock> time_point_t;
|
||||
typedef std::chrono::time_point<std::chrono::high_resolution_clock> time_point_t;
|
||||
|
||||
using namespace std::chrono;
|
||||
using namespace filament;
|
||||
@@ -55,10 +56,11 @@ namespace flutter_filament
|
||||
|
||||
class FilamentViewer
|
||||
{
|
||||
|
||||
|
||||
typedef int32_t EntityId;
|
||||
|
||||
public:
|
||||
FilamentViewer(const void *context, const ResourceLoaderWrapper *const resourceLoaderWrapper, void *const platform = nullptr, const char *uberArchivePath = nullptr);
|
||||
FilamentViewer(const void *context, const ResourceLoaderWrapperImpl *const resourceLoaderWrapper, void *const platform = nullptr, const char *uberArchivePath = nullptr);
|
||||
~FilamentViewer();
|
||||
|
||||
void setToneMapping(ToneMapping toneMapping);
|
||||
@@ -68,8 +70,7 @@ namespace flutter_filament
|
||||
|
||||
void loadIbl(const char *const iblUri, float intensity);
|
||||
void removeIbl();
|
||||
void rotateIbl(const math::mat3f & matrix);
|
||||
|
||||
void rotateIbl(const math::mat3f &matrix);
|
||||
|
||||
void removeEntity(EntityId asset);
|
||||
void clearEntities();
|
||||
@@ -98,7 +99,6 @@ namespace flutter_filament
|
||||
void setBackgroundImage(const char *resourcePath, bool fillHeight);
|
||||
void clearBackgroundImage();
|
||||
void setBackgroundImagePosition(float x, float y, bool clamp);
|
||||
|
||||
|
||||
// Camera methods
|
||||
void moveCameraToAsset(EntityId entityId);
|
||||
@@ -126,19 +126,19 @@ namespace flutter_filament
|
||||
void scrollUpdate(float x, float y, float delta);
|
||||
void scrollEnd();
|
||||
void pick(uint32_t x, uint32_t y, void (*callback)(EntityId entityId, int x, int y));
|
||||
|
||||
|
||||
EntityId addLight(LightManager::Type t, float colour, float intensity, float posX, float posY, float posZ, float dirX, float dirY, float dirZ, bool shadows);
|
||||
void removeLight(EntityId entityId);
|
||||
void clearLights();
|
||||
void setPostProcessing(bool enabled);
|
||||
|
||||
void setRecording(bool recording);
|
||||
void setRecordingOutputDirectory(const char* path);
|
||||
void setRecordingOutputDirectory(const char *path);
|
||||
|
||||
void setAntiAliasing(bool msaaEnabled, bool fxaaEnabled, bool taaEnabled);
|
||||
void setDepthOfField();
|
||||
|
||||
EntityId createGeometry(float* vertices, uint32_t numVertices, uint16_t* indices, uint32_t numIndices, filament::RenderableManager::PrimitiveType primitiveType = RenderableManager::PrimitiveType::TRIANGLES, const char* materialPath = nullptr);
|
||||
EntityId createGeometry(float *vertices, uint32_t numVertices, uint16_t *indices, uint32_t numIndices, filament::RenderableManager::PrimitiveType primitiveType = RenderableManager::PrimitiveType::TRIANGLES, const char *materialPath = nullptr);
|
||||
|
||||
SceneManager *const getSceneManager()
|
||||
{
|
||||
@@ -146,12 +146,12 @@ namespace flutter_filament
|
||||
}
|
||||
|
||||
private:
|
||||
const ResourceLoaderWrapper *const _resourceLoaderWrapper;
|
||||
const ResourceLoaderWrapperImpl *const _resourceLoaderWrapper;
|
||||
|
||||
Scene *_scene = nullptr;
|
||||
View *_view = nullptr;
|
||||
Engine *_engine = nullptr;
|
||||
flutter_filament::ThreadPool* _tp = nullptr;
|
||||
flutter_filament::ThreadPool *_tp = nullptr;
|
||||
Renderer *_renderer = nullptr;
|
||||
RenderTarget *_rt = nullptr;
|
||||
Texture *_rtColor = nullptr;
|
||||
@@ -174,7 +174,7 @@ namespace flutter_filament
|
||||
float _frameInterval = 1000.0 / 60.0;
|
||||
|
||||
// Camera properties
|
||||
Camera *_mainCamera = nullptr; // the default camera added to every scene. If you want the *active* camera, access via View.
|
||||
Camera *_mainCamera = nullptr; // the default camera added to every scene. If you want the *active* camera, access via View.
|
||||
float _cameraFocalLength = 28.0f;
|
||||
float _cameraFocusDistance = 0.0f;
|
||||
Manipulator<double> *_manipulator = nullptr;
|
||||
@@ -185,8 +185,8 @@ namespace flutter_filament
|
||||
math::mat4f _cameraPosition;
|
||||
math::mat4f _cameraRotation;
|
||||
void _createManipulator();
|
||||
double _near = 0.05;
|
||||
double _far = 1000.0;
|
||||
double _near = 0.05;
|
||||
double _far = 1000.0;
|
||||
|
||||
ColorGrading *colorGrading = nullptr;
|
||||
|
||||
@@ -204,12 +204,12 @@ namespace flutter_filament
|
||||
void loadKtxTexture(std::string path, ResourceBuffer data);
|
||||
void loadPngTexture(std::string path, ResourceBuffer data);
|
||||
void loadTextureFromPath(std::string path);
|
||||
void savePng(void* data, size_t size, int frameNumber);
|
||||
|
||||
void savePng(void *data, size_t size, int frameNumber);
|
||||
|
||||
time_point_t _recordingStartTime = std::chrono::high_resolution_clock::now();
|
||||
time_point_t _fpsCounterStartTime = std::chrono::high_resolution_clock::now();
|
||||
|
||||
bool _recording = false;
|
||||
|
||||
bool _recording = false;
|
||||
std::string _recordingOutputDirectory = std::string("/tmp");
|
||||
std::mutex _recordingMutex;
|
||||
double _cumulativeAnimationUpdateTime = 0;
|
||||
@@ -217,8 +217,9 @@ namespace flutter_filament
|
||||
int _skippedFrames = 0;
|
||||
};
|
||||
|
||||
struct FrameCallbackData {
|
||||
FilamentViewer* viewer;
|
||||
struct FrameCallbackData
|
||||
{
|
||||
FilamentViewer *viewer;
|
||||
uint32_t frameNumber;
|
||||
};
|
||||
|
||||
110
dart_filament/native/include/ResourceBuffer.hpp
Normal file
110
dart_filament/native/include/ResourceBuffer.hpp
Normal file
@@ -0,0 +1,110 @@
|
||||
#ifndef RESOURCE_BUFFER_H
|
||||
#define RESOURCE_BUFFER_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
//
|
||||
// A ResourceBuffer is a unified interface for working with
|
||||
// binary assets across various platforms.
|
||||
// This is simply:
|
||||
// 1) a pointer to some data
|
||||
// 2) the length of the data
|
||||
// 3) an ID that can be passed back to the native platform to release the underlying asset when needed.
|
||||
//
|
||||
struct ResourceBuffer
|
||||
{
|
||||
const void *const data;
|
||||
const int32_t size;
|
||||
const int32_t id;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
ResourceBuffer(void *const data, int32_t size, int32_t id) : data(data), size(size), id(id) {}
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef struct ResourceBuffer ResourceBuffer;
|
||||
typedef void (*LoadFilamentResourceIntoOutPointer)(const char *uri, ResourceBuffer *out);
|
||||
typedef ResourceBuffer (*LoadFilamentResource)(const char *uri);
|
||||
typedef ResourceBuffer (*LoadFilamentResourceFromOwner)(const char *const, void *const owner);
|
||||
typedef void (*FreeFilamentResource)(ResourceBuffer);
|
||||
typedef void (*FreeFilamentResourceFromOwner)(ResourceBuffer, void *const owner);
|
||||
|
||||
struct ResourceLoaderWrapper
|
||||
{
|
||||
LoadFilamentResource loadResource;
|
||||
FreeFilamentResource freeResource;
|
||||
LoadFilamentResourceFromOwner loadFromOwner;
|
||||
FreeFilamentResourceFromOwner freeFromOwner;
|
||||
void *owner;
|
||||
LoadFilamentResourceIntoOutPointer loadToOut;
|
||||
};
|
||||
typedef struct ResourceLoaderWrapper ResourceLoaderWrapper;
|
||||
|
||||
#if defined(__cplusplus)
|
||||
|
||||
#include <thread>
|
||||
using namespace std::chrono_literals;
|
||||
namespace flutter_filament
|
||||
{
|
||||
|
||||
struct ResourceLoaderWrapperImpl : public ResourceLoaderWrapper
|
||||
{
|
||||
|
||||
ResourceLoaderWrapperImpl(LoadFilamentResource loader, FreeFilamentResource freeResource)
|
||||
{
|
||||
loadFromOwner = nullptr;
|
||||
freeFromOwner = nullptr;
|
||||
loadResource = loader;
|
||||
freeResource = freeResource;
|
||||
owner = nullptr;
|
||||
}
|
||||
|
||||
ResourceLoaderWrapperImpl(LoadFilamentResourceFromOwner loader, FreeFilamentResourceFromOwner freeResource, void *owner)
|
||||
{
|
||||
loadResource = nullptr;
|
||||
freeResource = nullptr;
|
||||
loadFromOwner = loader;
|
||||
freeFromOwner = freeResource;
|
||||
owner = owner;
|
||||
}
|
||||
|
||||
ResourceBuffer load(const char *uri) const
|
||||
{
|
||||
if (loadToOut)
|
||||
{
|
||||
ResourceBuffer rb(nullptr, 0, -1);
|
||||
loadToOut(uri, &rb);
|
||||
while (rb.size == 0)
|
||||
{
|
||||
std::this_thread::sleep_for(100ms);
|
||||
}
|
||||
|
||||
return rb;
|
||||
}
|
||||
else if (loadFromOwner)
|
||||
{
|
||||
auto rb = loadFromOwner(uri, owner);
|
||||
return rb;
|
||||
}
|
||||
auto rb = loadResource(uri);
|
||||
return rb;
|
||||
}
|
||||
|
||||
void free(ResourceBuffer rb) const
|
||||
{
|
||||
if (freeFromOwner)
|
||||
{
|
||||
freeFromOwner(rb, owner);
|
||||
}
|
||||
else
|
||||
{
|
||||
freeResource(rb);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -37,7 +37,7 @@ namespace flutter_filament
|
||||
class SceneManager
|
||||
{
|
||||
public:
|
||||
SceneManager(const ResourceLoaderWrapper *const loader,
|
||||
SceneManager(const ResourceLoaderWrapperImpl *const loader,
|
||||
Engine *engine,
|
||||
Scene *scene,
|
||||
const char *uberArchivePath);
|
||||
@@ -158,7 +158,7 @@ namespace flutter_filament
|
||||
|
||||
private:
|
||||
gltfio::AssetLoader *_assetLoader = nullptr;
|
||||
const ResourceLoaderWrapper *const _resourceLoaderWrapper;
|
||||
const ResourceLoaderWrapperImpl *const _resourceLoaderWrapper;
|
||||
Engine *_engine;
|
||||
Scene *_scene;
|
||||
gltfio::MaterialProvider *_ubershaderProvider = nullptr;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user