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 SceneViewingMode.
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(SceneViewingMode::Local, BasemapStyle::ArcGISTopographic)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::setClippingArea, then enable clipping by settingScene::setClippingEnabledtotrue. - Create a
LocalSceneViewobject to display the scene. - Set the initial viewpoint for the scene.
- Set the scene to the local scene view.
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
// [WriteFile Name=DisplayLocalSceneView, Category=Scenes]// [Legal]// 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// http://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.// [Legal]
#ifdef PCH_BUILD#include "pch.hpp"#endif // PCH_BUILD
// sample headers#include "DisplayLocalSceneView.h"
// ArcGIS Maps SDK headers#include "ArcGISSceneLayer.h"#include "ArcGISTiledElevationSource.h"#include "Camera.h"#include "ElevationSourceListModel.h"#include "Envelope.h"#include "LayerListModel.h"#include "LocalSceneQuickView.h"#include "MapTypes.h"#include "Point.h"#include "Scene.h"#include "SceneViewTypes.h"#include "SpatialReference.h"#include "Surface.h"#include "Viewpoint.h"
using namespace Esri::ArcGISRuntime;
DisplayLocalSceneView::DisplayLocalSceneView(QObject* parent /* = nullptr */) : QObject(parent), m_scene(new Scene(SceneViewingMode::Local, BasemapStyle::ArcGISTopographic, this)){ // create a new elevation source from Terrain3D REST service ArcGISTiledElevationSource* elevationSource = new ArcGISTiledElevationSource(QUrl("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer"), this);
// add the elevation source to the scene to display elevation m_scene->baseSurface()->elevationSources()->append(elevationSource);
ArcGISSceneLayer* sceneLayer = new ArcGISSceneLayer(QUrl("https://www.arcgis.com/home/item.html?id=7a63e9808a054d39964a8b4712c85657"), this);
m_scene->operationalLayers()->append(sceneLayer);}
DisplayLocalSceneView::~DisplayLocalSceneView() = default;
void DisplayLocalSceneView::init(){ // Register classes for QML qmlRegisterType<LocalSceneQuickView>("Esri.Samples", 1, 0, "LocalSceneView"); qmlRegisterType<DisplayLocalSceneView>("Esri.Samples", 1, 0, "DisplayLocalSceneViewSample");}
LocalSceneQuickView* DisplayLocalSceneView::localSceneView() const{ return m_localSceneView;}
// Set the view (created in QML)void DisplayLocalSceneView::setLocalSceneView(LocalSceneQuickView* localSceneView){ if (!localSceneView || localSceneView == m_localSceneView) { return; }
m_localSceneView = localSceneView; m_localSceneView->setArcGISScene(m_scene);
// Sets the clipping area. const Envelope envelope(19454578.8235, // xMin -5055381.4798, // yMin 19455518.8814, // xMax -5054888.4150, // yMax SpatialReference::webMercator()); // spatialReference m_scene->setClippingArea(envelope);
m_scene->setClippingEnabled(true);
// Sets the initial viewpoint. const Point lookAtPoint(19455578.6821, // x -5056336.2227, // y 1699.3366, // z SpatialReference::webMercator()); // spatialReference
const Camera camera(lookAtPoint, 338.7410, // heading 40.3763, // pitch 0.0); // roll
const Point point(19455026.8116, // x -5054995.7415, // y SpatialReference::webMercator()); // spatialReference
m_scene->setInitialViewpoint(Viewpoint(point, 8314.6991, // scale camera));
emit localSceneViewChanged();}// [WriteFile Name=DisplayLocalSceneView, Category=Scenes]// [Legal]// 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// http://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.// [Legal]
#ifndef DISPLAYLOCALSCENEVIEW_H#define DISPLAYLOCALSCENEVIEW_H
// Qt headers#include <QObject>
namespace Esri::ArcGISRuntime{ class Scene; class LocalSceneQuickView;} // namespace Esri::ArcGISRuntime
Q_MOC_INCLUDE("LocalSceneQuickView.h");
class DisplayLocalSceneView : public QObject{ Q_OBJECT
Q_PROPERTY(Esri::ArcGISRuntime::LocalSceneQuickView* localSceneView READ localSceneView WRITE setLocalSceneView NOTIFY localSceneViewChanged)
public: explicit DisplayLocalSceneView(QObject* parent = nullptr); ~DisplayLocalSceneView() override;
static void init();
signals: void localSceneViewChanged();
private: Esri::ArcGISRuntime::LocalSceneQuickView* localSceneView() const; void setLocalSceneView(Esri::ArcGISRuntime::LocalSceneQuickView* localSceneView);
Esri::ArcGISRuntime::Scene* m_scene = nullptr; Esri::ArcGISRuntime::LocalSceneQuickView* m_localSceneView = nullptr;};
#endif // DISPLAYLOCALSCENEVIEW_H// [WriteFile Name=DisplayLocalSceneView, Category=Scenes]// [Legal]// 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// http://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.// [Legal]
import QtQuickimport QtQuick.Controlsimport Esri.Samples
Item {
LocalSceneView { id: view anchors.fill: parent
Component.onCompleted: { // Set and keep the focus on SceneView to enable keyboard navigation forceActiveFocus(); } }
// Declare the C++ instance which creates the scene etc. and supply the view DisplayLocalSceneViewSample { id: model localSceneView: view }}// 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// http://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.
#include "DisplayLocalSceneView.h"
#include "ArcGISRuntimeEnvironment.h"
#include <QCommandLineParser>#include <QDir>#include <QGuiApplication>#include <QQmlApplicationEngine>#include <QSurfaceFormat>
int main(int argc, char* argv[]){#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) // Linux requires 3.2 OpenGL Context // in order to instance 3D symbols QSurfaceFormat fmt = QSurfaceFormat::defaultFormat(); fmt.setVersion(3, 2); QSurfaceFormat::setDefaultFormat(fmt);#endif
QGuiApplication app(argc, argv); app.setApplicationName(QString("DisplayLocalSceneView"));
// Use of ArcGIS location services, such as basemap styles, geocoding, and routing services, // requires an access token. For more information see // https://links.esri.com/arcgis-runtime-security-auth.
// The following methods grant an access token:
// 1. User authentication: Grants a temporary access token associated with a user's ArcGIS account. // To generate a token, a user logs in to the app with an ArcGIS account that is part of an // organization in ArcGIS Online or ArcGIS Enterprise.
// 2. API key authentication: Get a long-lived access token that gives your application access to // ArcGIS location services. Go to the tutorial at https://links.esri.com/create-an-api-key. // Copy the API Key access token.
const QString accessToken = QString("");
if (accessToken.isEmpty()) { qWarning() << "Use of ArcGIS location services, such as the basemap styles service, requires" << "you to authenticate with an ArcGIS account or set the API Key property."; } else { Esri::ArcGISRuntime::ArcGISRuntimeEnvironment::setApiKey(accessToken); }
// Initialize the sample DisplayLocalSceneView::init();
// Initialize application view QQmlApplicationEngine engine; // Add the import Path engine.addImportPath(QDir(QCoreApplication::applicationDirPath()).filePath("qml"));
#ifdef ARCGIS_RUNTIME_IMPORT_PATH_2 engine.addImportPath(ARCGIS_RUNTIME_IMPORT_PATH_2);#endif
// Set the source engine.load(QUrl("qrc:/Samples/Scenes/DisplayLocalSceneView/main.qml"));
return app.exec();}// 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// http://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 QtQuick.Controlsimport Esri.Samples
ApplicationWindow { visible: true width: 800 height: 600
DisplayLocalSceneView { anchors.fill: parent }}