m-r-davari / flutter_3d_controller

The most complete Flutter package for rendering interactive 3D models in various formats (GLB, GLTF, OBJ, FBX), with the ability to control animations, textures, camera, and more.
https://pub.dev/packages/flutter_3d_controller
MIT License
109 stars 15 forks source link

Cannot create second 3d controller - it just duplicates first one #36

Closed shegal closed 1 month ago

shegal commented 1 month ago

I have viewer with controller on the main screen and they work perfectly fine. But if I try to create second viewer in modal window (so first viewer still present on screen) with another controller it seems like both controllers are the same and control viewer on the main screen.

m-r-davari commented 1 month ago

You need to create separate controller for each model viewer, for example if you have 3 model viewer then you need to create 3 controller

shegal commented 1 month ago

Of course I do create separate controllers (can provide you with code example if it is necessary). Seems like there is something underhood the controller with shared state or something like that.

m-r-davari commented 1 month ago

Ok then send your code for further progress, because I can't see the issue you mentioned in my case

shegal commented 1 month ago

It is just yours modified example. Take a note, that controller is attached to second model viewer but in fact it displays textures from first model viewer. If two controllers are created (viewer1 - controller1 and viewer2 - controller2, controller2 is attached to viewer1 also).

main.zip image

m-r-davari commented 1 month ago

Hi again, I checked your code, there is a bug with controller references. Thanks a lot for reporting this issue and helping me improving this package. I will fix this issue in next version as soon as possible.

m-r-davari commented 1 month ago

I have fixed this issue in v2.0.2. Please check out the latest version. https://pub.dev/packages/flutter_3d_controller

Let me know if you find any other issues.

shegal commented 1 month ago

Yes, now it is working! Thanks a lot!