Choose camera controller

View inAndroidFormsUWPWPFWinUIiOSView on GitHub

Control the behavior of the camera in a scene.

Image of choose camera controller

Use case

The globe camera controller (the default camera controller in all new scenes) allows a user to explore the scene freely by zooming in/out and panning around the globe. The orbit camera controllers fix the camera to look at a target location or geoelement. A primary use case is for following moving objects like cars and planes.

How to use the sample

The application loads with the "Orbit camera around plane" option (i.e. camera will now be fixed to the plane). Choose the "Orbit camera around location" option to rotate and center the scene around the location of the Upheaval Dome crater structure, or choose the "Free pan round the globe" option to go to default free navigation.

How it works

  1. Create an instance of a class extending CameraController: GlobeCameraController, OrbitLocationCameraController, OrbitGeoElementCameraController.
  2. Set the scene view's camera controller with SceneView.CameraController = cameraController.

Relevant API

  • Camera
  • GlobeCameraController
  • OrbitGeoElementCameraController
  • OrbitLocationCameraController
  • Scene
  • SceneView

Tags

3D, camera, camera controller

Sample Code

ChooseCameraController.xamlChooseCameraController.xamlChooseCameraController.xaml.cs
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<ContentPage x:Class="ArcGISRuntimeXamarin.Samples.ChooseCameraController.ChooseCameraController"
             xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Xamarin.Forms;assembly=Esri.ArcGISRuntime.Xamarin.Forms">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*" />
            <RowDefinition Height="auto" />
        </Grid.RowDefinitions>
        <esriUI:SceneView x:Name="MySceneView" Grid.Row="0" />
        <Button x:Name="ControllersButton"
                Grid.Row="1"
                Clicked="OnButtonClicked"
                Text="Change Camera Controller" />
    </Grid>
</ContentPage>

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.