Add a layer to visualize 3D tiles data that conforms to the OGC 3D Tiles specification.

Use case
One possible use case could be is that when added to a scene, a 3D tiles layer can assist in performing visual analysis, such as line of sight analysis. A line of sight analysis can be used to assess whether a view is obstructed between an observer and a target.
How to use the sample
When loaded, the sample will display a scene with an Ogc3DTilesLayer. Pan around and zoom in to observe the scene of the Ogc3DTilesLayer. Notice how the layer’s level of detail changes as you zoom in and out from the layer.
How it works
- Create a scene.
- Create an
Ogc3DTilesLayerwith the URL to a 3D tiles layer service. - Add the layer to the scene’s operational layers.
Relevant API
- Ogc3DTilesLayer
- SceneView
About the data
A layer to visualize 3D tiles data that conforms to the OGC 3D Tiles specification. As of 200.4, it supports analyses like viewshed and line of sight, but does not support other operations like individual feature identification.
The 3D Tiles Open Geospatial Consortium (OGC) specification defines a spatial data structure and a set of tile formats designed for streaming and rendering 3D geospatial content. A 3D Tiles data set, known as a tileset, defines one or more tile formats organized into a hierarchical spatial data structure. For more information, see the OGC 3D Tiles specification.
Tags
3d tiles, layers, OGC, OGC API, scene, service
Sample Code
// [WriteFile Name=Add3DTilesLayer, Category=Scenes]// [Legal]// Copyright 2023 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 "Add3DTilesLayer.h"
// ArcGIS Maps SDK headers#include "ArcGISTiledElevationSource.h"#include "Basemap.h"#include "Camera.h"#include "ElevationSourceListModel.h"#include "Layer.h"#include "LayerListModel.h"#include "MapTypes.h"#include "Ogc3dTilesLayer.h"#include "Scene.h"#include "SceneQuickView.h"#include "Surface.h"
using namespace Esri::ArcGISRuntime;
Add3DTilesLayer::Add3DTilesLayer(QObject* parent /* = nullptr */): QObject(parent), m_scene(new Scene(BasemapStyle::ArcGISDarkGray, 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);
add3DTilesLayer();}
Add3DTilesLayer::~Add3DTilesLayer() = default;
void Add3DTilesLayer::init(){ // Register classes for QML qmlRegisterType<SceneQuickView>("Esri.Samples", 1, 0, "SceneView"); qmlRegisterType<Add3DTilesLayer>("Esri.Samples", 1, 0, "Add3DTilesLayerSample");}
SceneQuickView* Add3DTilesLayer::sceneView() const{ return m_sceneView;}
// Set the view (created in QML)void Add3DTilesLayer::setSceneView(SceneQuickView* sceneView){ if (!sceneView || sceneView == m_sceneView) return;
m_sceneView = sceneView; m_sceneView->setArcGISScene(m_scene);
emit sceneViewChanged();
setInitialViewpoint();}
void Add3DTilesLayer::add3DTilesLayer(){ const QUrl modelPath = QUrl("https://tiles.arcgis.com/tiles/ZQgQTuoyBrtmoGdP/arcgis/rest/services/Stuttgart/3DTilesServer/tileset.json"); m_ogc3dTilesLayer = new Ogc3dTilesLayer(modelPath, this); m_scene->operationalLayers()->append(m_ogc3dTilesLayer);}
void Add3DTilesLayer::setInitialViewpoint(){ // add a camera constexpr double latitude = 48.8418; constexpr double longitude = 9.1536; constexpr double altitude = 1325.0; constexpr double heading = 48.3497; constexpr double pitch = 57.8414; constexpr double roll = 0.0; const Camera sceneCamera(latitude, longitude, altitude, heading, pitch, roll); m_sceneView->setViewpointCameraAndWait(sceneCamera);}// [WriteFile Name=Add3DTilesLayer, Category=Scenes]// [Legal]// Copyright 2023 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 ADD3DTILESLAYER_H#define ADD3DTILESLAYER_H
// Qt headers#include <QObject>
namespace Esri::ArcGISRuntime{class Scene;class SceneQuickView;class Ogc3dTilesLayer;}
Q_MOC_INCLUDE("SceneQuickView.h");
class Add3DTilesLayer : public QObject{ Q_OBJECT
Q_PROPERTY(Esri::ArcGISRuntime::SceneQuickView* sceneView READ sceneView WRITE setSceneView NOTIFY sceneViewChanged)
public: explicit Add3DTilesLayer(QObject* parent = nullptr); ~Add3DTilesLayer() override; static void init();
signals: void sceneViewChanged();
private: Esri::ArcGISRuntime::SceneQuickView* sceneView() const; void setSceneView(Esri::ArcGISRuntime::SceneQuickView* sceneView);
Esri::ArcGISRuntime::Scene* m_scene = nullptr; Esri::ArcGISRuntime::SceneQuickView* m_sceneView = nullptr;
// add 3D tiles layer Esri::ArcGISRuntime::Ogc3dTilesLayer* m_ogc3dTilesLayer = nullptr; void add3DTilesLayer();
void setInitialViewpoint();};
#endif // ADD3DTILESLAYER_H// [WriteFile Name=Add3DTilesLayer, Category=Scenes]// [Legal]// Copyright 2023 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 {
SceneView { 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 Add3DTilesLayerSample { id: model sceneView: view }}// [Legal]// Copyright 2023 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]
// sample headers#include "Add3DTilesLayer.h"
// ArcGIS Maps SDK headers#include "ArcGISRuntimeEnvironment.h"
// Qt headers#include <QCommandLineParser>#include <QDir>#include <QGuiApplication>#include <QQmlApplicationEngine>#include <QSurfaceFormat>
// Platform specific headers#ifdef Q_OS_WIN#include <Windows.h>#endif
int main(int argc, char *argv[]){ Esri::ArcGISRuntime::ArcGISRuntimeEnvironment::setUseLegacyAuthentication(false);#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("Add3DTilesLayer"));
// 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 Add3DTilesLayer::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/Add3DTilesLayer/main.qml"));
return app.exec();}// Copyright 2023 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
Add3DTilesLayer { anchors.fill: parent }}