Add 3d tiles layer

View on GitHubSample viewer app

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

Add 3D Tiles Layer

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

  1. Create a scene.
  2. Create an Ogc3DTilesLayer with the URL to a 3D tiles layer service.
  3. 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

Add3dTilesLayerSample.java
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
/*
 * Copyright 2024 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.
 */

package com.esri.samples.add_3d_tiles_layer;

import com.esri.arcgisruntime.ArcGISRuntimeEnvironment;
import com.esri.arcgisruntime.layers.Ogc3DTilesLayer;
import com.esri.arcgisruntime.loadable.LoadStatus;
import com.esri.arcgisruntime.mapping.ArcGISScene;
import com.esri.arcgisruntime.mapping.ArcGISTiledElevationSource;
import com.esri.arcgisruntime.mapping.BasemapStyle;
import com.esri.arcgisruntime.mapping.view.Camera;
import com.esri.arcgisruntime.mapping.view.SceneView;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Alert;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

public class Add3dTilesLayerSample extends Application {
  private SceneView sceneView;
  private ArcGISScene arcGISScene;

  @Override
  public void start(Stage stage) {

    try {
      // create stack pane and application scene
      StackPane stackPane = new StackPane();
      Scene fxScene = new Scene(stackPane);

      // set title, size, and add scene to stage
      stage.setTitle("Add 3D Tiles Layer Sample");
      stage.setWidth(800);
      stage.setHeight(700);
      stage.setScene(fxScene);
      stage.show();

      // create a new elevation source from Terrain3D REST service
      ArcGISTiledElevationSource elevationSource = new ArcGISTiledElevationSource(
          "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer");

      // authentication with an API key or named user is required to access basemaps and other location services
      String yourAPIKey = System.getProperty("apiKey");
      ArcGISRuntimeEnvironment.setApiKey(yourAPIKey);

      arcGISScene = new ArcGISScene(BasemapStyle.ARCGIS_DARK_GRAY);

      arcGISScene.getBaseSurface().getElevationSources().add(elevationSource);
      add3DTilesLayer();

      sceneView = new SceneView();

      arcGISScene.addDoneLoadingListener(() -> {
        if (arcGISScene.getLoadStatus() == LoadStatus.FAILED_TO_LOAD) {
          new Alert(Alert.AlertType.ERROR,
              "Scene failed to load: " + arcGISScene.getLoadError().getCause().getMessage()).show();
        }
      });

      sceneView.setArcGISScene(arcGISScene);
      setInitialViewpoint();

      // add the scene view to the stack pane
      stackPane.getChildren().add(sceneView);
    } catch (Exception e) {
      // on any error, display the stack trace.
      e.printStackTrace();
    }
  }

  private void setInitialViewpoint() {
    // add a camera
    double latitude = 48.84553;
    double longitude = 9.16275;
    double altitude = 350.0;
    double heading = 0.0;
    double pitch = 60;
    double roll = 0.0;
    Camera sceneCamera = new Camera(latitude, longitude, altitude, heading, pitch, roll);
    sceneView.setViewpointCamera(sceneCamera);
  }

  private void add3DTilesLayer() {
    String tilePath =
        "https://tiles.arcgis.com/tiles/ZQgQTuoyBrtmoGdP/arcgis/rest/services/Stuttgart/3DTilesServer/tileset.json";

    Ogc3DTilesLayer ogc3dTilesLayer = new Ogc3DTilesLayer(tilePath);
    arcGISScene.getOperationalLayers().add(ogc3dTilesLayer);
  }

  /**
   * Stops and releases all resources used in application.
   */
  @Override
  public void stop() {

    if (sceneView != null) {
      sceneView.dispose();
    }
  }

  /**
   * Opens and runs application.
   *
   * @param args arguments passed to this application
   */
  public static void main(String[] args) {

    Application.launch(args);
  }
}

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.