flutterdart3d-model

model_viewer_plus model pan enabled


I'm looking to add a pan to a 3d model.

I have a map and you can zoom into the map but there is no pan. is there any way to add this?

https://pub.dev/packages/model_viewer_plus/score

ModelViewer(
        backgroundColor: Color.fromARGB(0xFF, 0xEE, 0xEE, 0xEE),
        src: 'assets/map/ComplexMap.glb', // a bundled asset file
        alt: "Test",
        ar: false,
        autoRotate: false,
        cameraControls: true,
      );

Solution

  • Flutter does provide a widget that allows for panning and zooming of a child widget. This widget is called InteractiveViwer.

    To use this widget you will need to wrap the ModelViewer Widget within an InteractiveViewer like below

    InteractiveViewr(
        child: ModelViewer(
            backgroundColor: Color.fromARGB(0xFF, 0xEE, 0xEE, 0xEE),
            src: 'assets/map/ComplexMap.glb', // a bundled asset file
            alt: "Test",
            ar: false,
            autoRotate: false,
            cameraControls: true,
          );
    )
    

    Docs

    InteractiveViewer Widget