Scenes are the document used for persistence and sharing of 3D content on the ArcGIS platform. To learn about opening scenes from ArcGIS Online and Portal, see Display a scene. This guide describes how to create a new scene programmatically, add content, and show the scene in your app.
The data you visualize in your 3D app is defined by the scene class. The types of data you can display in a scene include:
- Basemaps, which can be draped over surface layers. A surface layer contains elevation information. Other layer types can also be used as a basemap; there are no special restrictions for basemaps in scenes.
- Operational layers, which can include feature layers or scene layers. Scene layers represent built and natural 3D content such as buildings, trees, valleys, and mountains and can be accessed as scene services or local scene layer packages.
- Surface layers, which define the elevation information of the 3D visualization. A surface layer can come in many forms, for example, local raster data such as a DEM or DTED or from an ArcGIS image service.
Add a scene layer from a service or package
- Create a scene that contains a basemap and a scene layer, either from a service or a local package.
// create a new scene with a topographic basemap var myScene = new Scene(Basemap.CreateTopographic()); // create a scene layer to display (3D) buildings var dddBuildingsLayer = new ArcGISSceneLayer(new System.Uri("http://scene.arcgis.com/arcgis/rest/services/Hosted/Buildings_Brest/SceneServer/layers/0")); // add the scene layer to the scene myScene.OperationalLayers.Add(dddBuildingsLayer);
You can also define a scene and its layers using XAML, as shown in the following example.
<esriUI:SceneView x:Name="MySceneView"> <mapping:Scene> <mapping:Scene.Basemap> <mapping:Basemap> <mapping:ArcGISTiledLayer Name="Topographic" Source="http://services.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"/> </mapping:Basemap> </mapping:Scene.Basemap> <mapping:ArcGISSceneLayer Name="BuildingsLayer" Source="http://scene.arcgis.com/arcgis/rest/services/Hosted/Buildings_Brest/SceneServer/layers/0"/> </mapping:Scene> </esriUI:SceneView>
- To display the scene, assign it to a scene view that you create.
// add a scene to the scene view MySceneView.Scene = myScene;
- Run the project and it should resemble the following image. You can use your mouse to pan and zoom around the scene. For more information on navigating the scene, see the Navigate a scene view topic.
Add a 3D surface (terrain)
Add a surface layer to a scene with a basemap for 3D visualization in your app.
- Create a scene and assign it to a scene view.
// create a new scene with a topographic basemap var myScene = new Scene(Basemap.CreateTopographic()); // add the new scene to the scene view MySceneView.Scene = myScene;
- Add an elevation surface and apply it to the scene.
// create an elevation source var elevationSource = new ArcGISTiledElevationSource(new System.Uri("http://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")); // create a surface and add the elevation surface var sceneSurface = new Surface(); sceneSurface.ElevationSources.Add(elevationSource); // apply the surface to the scene MySceneView.Scene.BaseSurface = sceneSurface;
You can use your mouse to pan and zoom around the scene. For more information on navigating the scene, see the Built-in navigation section of the "Navigate a scene view" topic.
Set the camera
The position you view the scene from is defined by a camera class. When you create a new camera class, you must define the following properties:
- 3D location—Latitude, longitude, and elevation
- Heading—Direction the camera is pointing towards
- Pitch—Up and down angle of camera
For example, to point the camera to toward the Snowdon mountainside, as shown in the following code snippet and image, use these values:
- For 3D location, use 53.06 latitude, -4.04 longitude, 1289 metres above sea level
- For heading, use 295 degrees
- For pitch, use 71 degrees
var snowdonCamera = new Camera(53.06, -4.04, 1289, 295, 71, 0);
Now you have a new camera you can apply to your scene view. You can apply it immediately using SetViewpointCamera as shown in the code below, or the camera can be animated to the new position using one of the asynchronous methods.
Create a scene layer package and local elevation source
ArcGIS Pro allows you to create a scene layer package using a geoprocessing tool. You can add this local scene layer package ( .slpk) as a scene layer ( ArcGISSceneLayer) to your ArcGIS Runtime app and add it to a Scene. To display the scene layer package, create a new scene layer with a URL pointing to a local scene layer package.
To take this scene layer offline your app can define an elevation surface by consuming local raster datasets on the client. The following formats are supported for creating a local elevation source:
- CIB1, 5, 10
- DTED0, 1, 2
- JPEG 2000
- SRTM1, 2