Display a local scene with a topographic surface and 3D scene layer clipped to a local area.
Use case
A LocalSceneView is a user interface that displays 3D basemaps and layer content described in a Scene with a local Scene.ViewingMode.
Unlike a global scene, which is drawn on a globe using a geographic coordinate system, a local scene is drawn on a flat surface and supports projected coordinate systems. They are generally used to view local data and are often clipped to a specific area of interest. Currently, LocalSceneView cannot display data provided by a global scene, and SceneView cannot display data provided by a local scene.
The LocalSceneView displays the clipped area of the local scene, supports user interactions such as pan and zoom, and provides access to the underlying scene data.
How to use the sample
This sample displays a local scene clipped to an extent. Pan and zoom to explore the scene.
How it works
- Create a local scene object with the
Scene(viewingMode:basemapStyle:)constructor. - Create an
ArcGISTiledElevationSourceobject and add it to the local scene's base surface. - Create an
ArcGISSceneLayerand add it to the local scene's operational layers. - Create an
Envelopeand set it to thescene.clippingArea, then enable clipping by settingscene.clippingIsEnabledtotrue. - Set the initial viewpoint for the local scene.
- Create a
LocalSceneViewinstance with the scene.
Relevant API
- ArcGISSceneLayer
- ArcGISTiledElevationSource
- LocalSceneView
- Scene
About the data
The scene layer in this sample shows 3D extruded rooftop outlines of buildings on the Victoria University campus and surrounding vicinity in Wellington, New Zealand.
Tags
3D, basemap, elevation, scene, surface
Sample Code
// Copyright 2025 Esri
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import ArcGIS
import SwiftUI
struct DisplayLocalSceneView: View {
/// A local scene with topographic basemap style and a tiled elevation source.
@State private var scene: ArcGIS.Scene = {
let scene = Scene(
viewingMode: .local,
basemapStyle: .arcGISTopographic
)
// Adds a surface.
let elevationSource = ArcGISTiledElevationSource(
url: URL(string: "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")!
)
scene.baseSurface.addElevationSource(elevationSource)
// Adds a layer.
let sceneLayer = ArcGISSceneLayer(
url: URL(string: "https://www.arcgis.com/home/item.html?id=7a63e9808a054d39964a8b4712c85657")!
)
scene.addOperationalLayer(sceneLayer)
// Sets the clipping area.
scene.clippingArea = Envelope(
xRange: 19_454_578.8235...19_455_518.8814,
yRange: -5_055_381.4798 ... -5_054_888.4150,
spatialReference: .webMercator
)
scene.clippingIsEnabled = true
// Sets the initial viewpoint.
let camera = Camera(
location: Point(
x: 19_455_578.6821,
y: -5_056_336.2227,
z: 1_699.3366,
spatialReference: .webMercator
),
heading: 338.7410,
pitch: 40.3763,
roll: 0
)
scene.initialViewpoint = Viewpoint(
center: Point(x: 19_455_026.8116, y: -5_054_995.7415, spatialReference: .webMercator),
scale: 8_314.6991,
camera: camera
)
return scene
}()
var body: some View {
// Creates a local scene view with a local scene.
LocalSceneView(scene: scene)
}
}
#Preview {
DisplayLocalSceneView()
}