omchiii / model_viewer_plus.dart

A Flutter widget for rendering interactive 3D models in the glTF and GLB formats.
https://pub.dev/packages/model_viewer_plus
Apache License 2.0
82 stars 47 forks source link

Rotation controls broken after showing a dialog #65

Open frantovar opened 1 year ago

frantovar commented 1 year ago

Describe the bug After showing a dialog over the modelViewer the model controls start failing and rotation don't work anymore. You can check the video here.

To reproduce Steps to reproduce the behavior:

  1. Place a dialog in the app bar. Check this example.
  2. Show the dialog
  3. Close it
  4. Now rotation controls are broken

Expected behavior After closing the dialog the model should be controller normally.

Simulator and real device

Additional context Add any other context about the problem here.

LesGrob commented 1 year ago

Have you found a solution? I have the same problem using ModelViewer inside IndexedStack.

Problem code ```dart return IndexedStack( index: stackIndex, children: [ ModelViewer( id: "modelViewBlock", src: "https://modelviewer.dev/shared-assets/models/Astronaut.glb", ar: false, autoRotate: true, cameraControls: true, loading: Loading.eager, touchAction: TouchAction.none, enablePan: false, disableZoom: false, interactionPolicy: InteractionPolicy.alwaysAllow, ), Container(color: Colors.amber), ], ); ```

I've tried to reproduce such problem with WebView, but it works fine:

WebView solution ```dart return IndexedStack( index: stackIndex, children: [ WebView( backgroundColor: Colors.transparent, initialUrl: "https://modelviewer.dev/", javascriptMode: JavascriptMode.unrestricted, initialMediaPlaybackPolicy: AutoMediaPlaybackPolicy.always_allow, gestureRecognizers: >{ Factory( () => EagerGestureRecognizer(), ), }, ), Container(color: Colors.amber), ], ); ```

Any ideas what it could be?

LesGrob commented 1 year ago

I figured out that the problem isn't with Stack but with widgets in it. There is what i mean: If there are widgets in Stack above ModelViewer then ModelViewer’s gesture detector cracks after clicking on any widget above it. Here is code to reproduce problem:

return Scaffold(
      body: Stack(children: [
        ModelViewer(
          id: "modelViewBlock",
          src: "https://modelviewer.dev/shared-assets/models/Astronaut.glb",
          ar: false,
          backgroundColor: Colors.green,
          loading: Loading.eager,
          cameraControls: true,
          touchAction: TouchAction.none,
          enablePan: false,
          disableZoom: false,
          autoRotate: true,
        ),
        Positioned(
          bottom: 20 + MediaQuery.of(context).padding.bottom,
          left: 40,
          width: 40,
          height: 40,
          child: Container(color: Colors.red),
        ),
      ]),
    );

It can be fixed by covering above widgets with IgnorePointer:

return Scaffold(
      body: Stack(children: [
        ModelViewer(
          id: "modelViewBlock",
          src: "https://modelviewer.dev/shared-assets/models/Astronaut.glb",
          ar: false,
          backgroundColor: Colors.green,
          loading: Loading.eager,
          cameraControls: true,
          touchAction: TouchAction.none,
          enablePan: false,
          disableZoom: false,
          autoRotate: true,
        ),
        Positioned(
          bottom: 20 + MediaQuery.of(context).padding.bottom,
          left: 40,
          width: 40,
          height: 40,
          child: IgnorePointer(
            child: Container(color: Colors.red),
          ),
        ),
      ]),
    );

But it’s still problem to use GestureDetectors above ModelViewer. I think ModelViewer make "+1 pan" after clicking on widget. So after one click it start to zoom model when only one finger on screen. And absolutely stucks after the second tap. Here is video: https://user-images.githubusercontent.com/44160618/218119132-81b333f5-7298-4256-a566-c8df0ffbf168.mp4

hellhorse123 commented 11 months ago

07/01/2023, the error persists. I still can't click on the buttons on the scene with the model. Has anyone found a solution? And this problem is reproduced only on ios. On Android devices, all buttons work correctly