View in MAUI WPF WinUI View on GitHub

An OrbitGeoElementCameraController follows a graphic while the graphic’s position and rotation are animated.

Image of animate 3D graphic

Use case

Visualize movement through a 3D landscape.

How to use the sample

Animation Controls:

  • Select a mission — select a flight path
  • Play/Pause — toggles playing and stopping the animation
  • Follow/Don’t follow — toggles the camera’s free cam mode and follow
  • Mission progress — shows how far along the route the plane is. Slide to change keyframe in animation
  • Flight speed — controls speed of animation

How it works

  1. Create a GraphicsOverlay and add it to the SceneView.
  2. Create a ModelSceneSymbol object.
  3. Create a Graphic object and set its geometry to a Point.
  4. Set the ModelSceneSymbol object to the graphic.
  5. Add heading, pitch, and roll attributes to the graphic. Get the attributes from the graphic with Graphic.attributes.
  6. Create a SimpleRenderer object and set its expression properties.
  7. Add graphic and a renderer to the graphics overlay.
  8. Create a OrbitGeoElementCameraController which is set to target the graphic.
  9. Assign the camera controller to the SceneView.
  10. Update the graphic’s location, heading, pitch, and roll.

Relevant API

  • Camera
  • GlobeCameraController
  • Graphic
  • GraphicsOverlay
  • ModelSceneSymbol
  • OrbitGeoElementCameraController
  • Renderer
  • Scene
  • SceneProperties
  • SceneView
  • SurfacePlacement

Offline data

This sample downloads the following items from ArcGIS Online automatically:

Tags

animation, camera, heading, pitch, roll, rotation, visualize

Sample Code

Animate3DGraphic.xaml Animate3DGraphic.xaml Animate3DGraphic.xaml.cs
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage x:Class="ArcGIS.Samples.Animate3DGraphic.Animate3DGraphic"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:esriUI="clr-namespace:Esri.ArcGISRuntime.Maui;assembly=Esri.ArcGISRuntime.Maui">
<Grid Style="{DynamicResource EsriSampleContainer}">
<esriUI:SceneView x:Name="MySceneView"
AtmosphereEffect="Realistic"
Style="{DynamicResource EsriSampleGeoView}" />
<Border Style="{DynamicResource EsriSampleControlPanel}">
<ScrollView>
<StackLayout Spacing="5">
<Label FontAttributes="Bold" Text="Select a mission:" />
<Picker x:Name="MissionSelectionBox" />
<Label FontAttributes="Bold" Text="Mission progress:" />
<Slider x:Name="MissionProgressBar"
Maximum="100"
ValueChanged="MissionProgressBar_ValueChanged" />
<Label FontAttributes="Bold" Text="Play mission:" />
<Switch x:Name="PlaySwitch"
HorizontalOptions="Start"
Toggled="PlaySwitch_Toggled" />
<Label FontAttributes="Bold" Text="Follow plane:" />
<Switch x:Name="FollowSwitch"
HorizontalOptions="Start"
Toggled="FollowSwitch_Toggled" />
<Label>
<Label.FormattedText>
<FormattedString>
<Span FontAttributes="Bold" Text="Altitude: " />
<Span x:Name="AltitudeLabel" />
</FormattedString>
</Label.FormattedText>
</Label>
<Label>
<Label.FormattedText>
<FormattedString>
<Span FontAttributes="Bold" Text="Heading: " />
<Span x:Name="HeadingLabel" />
</FormattedString>
</Label.FormattedText>
</Label>
<Label>
<Label.FormattedText>
<FormattedString>
<Span FontAttributes="Bold" Text="Pitch: " />
<Span x:Name="PitchLabel" />
</FormattedString>
</Label.FormattedText>
</Label>
<Label>
<Label.FormattedText>
<FormattedString>
<Span FontAttributes="Bold" Text="Roll: " />
<Span x:Name="RollLabel" />
</FormattedString>
</Label.FormattedText>
</Label>
<esriUI:MapView x:Name="InsetMapView"
HeightRequest="200"
IsAttributionTextVisible="False" />
</StackLayout>
</ScrollView>
</Border>
</Grid>
</ContentPage>