flutter_3d_controller icon indicating copy to clipboard operation
flutter_3d_controller copied to clipboard

No way to determine when controller is ready (model is loaded)

Open shegal opened this issue 1 year ago • 3 comments

Problem: Need to play a specific animation and set camera to a specific position when model is loaded. Animations and positions are not same every time, so setting it via glb is not an option (if it's even possible for glb)

Possible solutions:

  • add a callback which triggers when model is loaded
  • specify initial animation and camera position for controller which is set after model is loaded

shegal avatar May 28 '24 16:05 shegal

Hi, About the callback which triggers after model loads completely, its good idea I will add it in next version, or if you can please do it and create PR. it will be a helpful

About initial animation and camera position you mentioned.

I also will add initial cameraTarget and initial cameraOrbit argument to the either Flutter3dController class or Flutter3DViewer widget

more info may be useful for you :

If you call the playAnimation() method without passing animation name and model has at least 1 animation, package will play first animation by default.

cameraTarget default value is = "auto auto auto" cameraOrbit default value is = "0deg 75deg 105%"

m-r-davari avatar Jun 04 '24 09:06 m-r-davari

I actually tried to add callback by myself, but didn't manage to do it via existing dart code and I have zero experience with JS so again didn't manage to find a quick solution inside web views / model viewer.

shegal avatar Jun 07 '24 09:06 shegal

Any update on this?

PhantomKnight287 avatar Jul 07 '24 14:07 PhantomKnight287

Feature has been added in v2.0.0 ✅

  • Controller model loading value listener
  • Model loading states callbacks, onProgress, onLoad and onError

controller.onModelLoaded.addListener(() { //do something}); onLoad: (String modelAddress) { debugPrint('model loaded : $modelAddress'); },

checkout latest version

m-r-davari avatar Oct 05 '24 06:10 m-r-davari