Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Displaying multiple FilamentWidgets #18

Open
Hannnes1 opened this issue Feb 23, 2024 · 4 comments
Open

Displaying multiple FilamentWidgets #18

Hannnes1 opened this issue Feb 23, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@Hannnes1
Copy link
Contributor

Hi,
I tried to display multiple models at once, by creating multiple FilamentWidgets, but it seems like that is not possible at the moment. All widgets except the first throws the following error:

E/flutter (17528): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: PlatformException(TEXTURE_EXISTS, Texture already exist. Make sure you call destroyTexture first, null, null)
E/flutter (17528): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:651:7)
E/flutter (17528): #1      MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18)
E/flutter (17528): <asynchronous suspension>
E/flutter (17528): #2      FilamentControllerFFI._createRenderingSurface (package:flutter_filament/filament_controller_ffi.dart:242:34)
E/flutter (17528): <asynchronous suspension>
E/flutter (17528): #3      FilamentControllerFFI.createViewer (package:flutter_filament/filament_controller_ffi.dart:203:28)
E/flutter (17528): <asynchronous suspension>
E/flutter (17528): #4      _MedalState.initState.<anonymous closure> (package:filament_playground/main.dart:98:7)
E/flutter (17528): <asynchronous suspension>

I also got the same error after hot restarting, if .createViewer() is called in initState(). Not entirely sure if the cause is the same though.

createViewer() has the doc comment "You do not need to call this yourself.", so I tried removing it. However that caused the exception "No viewer available". I guess that the documentation isn't entirely up to date in the development branch?

Thanks for a great package!

@Hannnes1 Hannnes1 changed the title Displaying multiple Displaying multiple FilamentWidgets Feb 23, 2024
@nmfisher
Copy link
Owner

At the moment only a single FilamentWidget is supported, so to load multiple models, you just load them into the same scene/view and translate them (or the camera) as necessary.

I could restructure things to accommodate multiple FilamentWidget (on the backend we would create a texture/view/camera for each new widget). What use case did you have in mind for multiple widgets?

@Hannnes1
Copy link
Contributor Author

The end goal I'm looking for is something like this, where the yellow squares will be 3D models.

clip.mp4

The grid I can probably solve with only one FilamentWidget, but the Hero animation to the second screen is trickier. Even two FilamentWidgets on different screens causes the error, since the first screen is still in the navigation stack.

Although. Now that I think about it, I might be able to use one widget for everything, and do a hero animation entirely in the 3D viewer. Will require more math though.

@nmfisher
Copy link
Owner

That's possible, but would need quite a bit of work to implement on both the C++ and Dart sides. Everything so far has been written with the assumption of a single engine/scene/view/render target (texture)/render loop, so we'd need to go back in and refactor some things to allow creating new views/textures/etc. If you need something now, you're probably better off doing the animation in the viewer itself - I've done similar things (basically hard-coding animations in Blender then just triggering them in the app). That might be an easier short term solution.

@Hannnes1
Copy link
Contributor Author

Okay, I get it.
I will see what I can do within the viewer itself instead.

@nmfisher nmfisher added the enhancement New feature or request label Feb 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants