Add a layer to a local scene to visualize and interact with 3D building models developed using Building Information Modeling (BIM) tools.
Use case
Building Scene Layers allow you to display and analyze detailed building models created from 3D BIM data. Unlike 3D object scene layers, which represent all features within a single layer, Building Scene Layers are organized into a hierarchy of sublayers representing individual building components such as walls, light fixtures, and mechanical systems. These sublayers are often grouped by disciplines like Architectural, Mechanical, or Structural. This structure enables deeper interaction and analysis of both interior and exterior features, providing insight into how a building is designed, used, and situated in its spatial context.
How to use the sample
When loaded, the sample displays a scene with a Building Scene Layer. By default, the Overview sublayer is visible, showing the building's exterior shell. Use the "Full Model" toggle to switch to the Full Model sublayer, which reveals the building's components. Pan around and zoom in to observe the detailed features such as walls, light fixtures, mechanical systems, and more, both outside and inside the building.
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 a
BuildingSceneLayerand add it to the local scene's operational layers. - Create a
LocalSceneViewobject to display the scene. - Set the local scene to the
LocalSceneView.
Relevant API
- ArcGISTiledElevationSource
- BuildingSceneLayer
- BuildingSublayer
- LocalSceneView
- Scene
Tags
3D, buildings, elevation, layers, 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 AddBuildingSceneLayerView: 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)
return scene
}()
/// A Boolean value that indicates if the full model of the building scene layer is visible or not.
@State private var fullModelIsVisible = false
/// The camera for zooming the local scene view to the building scene layer.
@State private var camera: Camera? = Camera(
location: Point(x: -13_045_109, y: 4_036_614, z: 511, spatialReference: .webMercator),
heading: 343,
pitch: 64,
roll: 0
)
/// The overview sublayer which represents the exterior shell of the building.
@State private var overviewSublayer: BuildingSublayer?
/// The full model sublayer which contains all the features of the building.
@State private var fullModelSublayer: BuildingSublayer?
var body: some View {
LocalSceneView(scene: scene, camera: $camera)
.task {
let buildingSceneLayer = BuildingSceneLayer(
url: URL(string: "https://www.arcgis.com/home/item.html?id=669f6279c579486eb4a0acc7eb59d7ca")!
)
// Sets the altitude offset of the building scene layer.
// Upon first inspection of the model, it does not line up
// with the global elevation layer perfectly. To fix this,
// add an altitude offset to align the model with the
// ground surface.
buildingSceneLayer.altitudeOffset = 1
// Explicitly loading the layer to retrieve the sublayers.
try? await buildingSceneLayer.load()
// Adds building scene layer to scene.
scene.addOperationalLayer(buildingSceneLayer)
// Gets the overview and full model sublayers for the toggle.
let sublayers = buildingSceneLayer.sublayers
overviewSublayer = sublayers.first(where: { $0.modelName == "Overview" })
fullModelSublayer = sublayers.first(where: { $0.modelName == "FullModel" })
}
.toolbar {
ToolbarItem(placement: .bottomBar) {
// Shows the toggle when we have a valid full model
// sublayer since we need that for the toggle.
if fullModelSublayer != nil {
Toggle("Full Model", isOn: $fullModelIsVisible)
#if targetEnvironment(macCatalyst)
.toggleStyle(.switch)
#endif
} else {
ProgressView()
}
}
}
.onChange(of: fullModelIsVisible) {
// Toggle the visibility of the full model sublayer.
// This does not affect the 'isVisible' property of
// individual sublayers within the full model.
fullModelSublayer?.isVisible = fullModelIsVisible
// The overview sublayer represents the exterior shell of
// the building. The full model sublayer includes this
// shell along with interior components. To avoid rendering
// artifacts like z-fighting and redundant drawing, we
// only display one at a time.
overviewSublayer?.isVisible = !fullModelIsVisible
}
}
}
#Preview {
AddBuildingSceneLayerView()
}