Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions samples/add-building-scene-layer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Add building scene layer

Add a layer to a local scene to visualize and interact with 3D building models developed using Building Information Modeling (BIM) tools.

![Image of add building scene layer](add-building-scene-layer.png)

## 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

1. Create a local scene object with the `ArcGISScene(BasemapStyle, SceneViewingMode)` constructor.
2. Create an `ArcGISTiledElevationSource` object and add it to the local scene's base surface.
3. Create a `BuildingSceneLayer` and add it to the local scene's operational layers.
4. Create a `LocalSceneView` object to display the scene.
5. Set the local scene to the `LocalSceneView`.

## Relevant API

* ArcGISTiledElevationSource
* BuildingSceneLayer
* BuildingSublayer
* LocalSceneView
* Scene

## Tags

3D, buildings, elevation, layers, scene, surface
36 changes: 36 additions & 0 deletions samples/add-building-scene-layer/README.metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"category": "Layers",
"description": "Add a layer to a local scene to visualize and interact with 3D building models developed using Building Information Modeling (BIM) tools.",
"formal_name": "AddBuildingSceneLayer",
"ignore": false,
"images": [
"add-building-scene-layer.png"
],
"keywords": [
"3D",
"buildings",
"elevation",
"layers",
"scene",
"surface",
"ArcGISTiledElevationSource",
"BuildingSceneLayer",
"BuildingSublayer",
"LocalSceneView",
"Scene"
],
"language": "kotlin",
"redirect_from": "",
"relevant_apis": [
"ArcGISTiledElevationSource",
"BuildingSceneLayer",
"BuildingSublayer",
"LocalSceneView",
"Scene"
],
"snippets": [
"src/main/java/com/esri/arcgismaps/sample/addbuildingscenelayer/MainActivity.kt",
"src/main/java/com/esri/arcgismaps/sample/addbuildingscenelayer/screens/AddBuildingSceneLayerScreen.kt"
],
"title": "Add building scene layer"
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions samples/add-building-scene-layer/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
plugins {
alias(libs.plugins.arcgismaps.android.library)
alias(libs.plugins.arcgismaps.android.library.compose)
alias(libs.plugins.arcgismaps.kotlin.sample)
alias(libs.plugins.gradle.secrets)
}

secrets {
// this file doesn't contain secrets, it just provides defaults which can be committed into git.
defaultPropertiesFileName = "secrets.defaults.properties"
}

android {
namespace = "com.esri.arcgismaps.sample.addbuildingscenelayer"
buildFeatures {
buildConfig = true
}
}

dependencies {
// Only module specific dependencies needed here
}
14 changes: 14 additions & 0 deletions samples/add-building-scene-layer/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />

<application><activity
android:exported="true"
android:name=".MainActivity"
android:label="@string/add_building_scene_layer_app_name">

</activity>
</application>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/* 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.
*
*/

package com.esri.arcgismaps.sample.addbuildingscenelayer

import android.os.Bundle
import androidx.activity.ComponentActivity
import androidx.activity.compose.setContent
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
import com.arcgismaps.ApiKey
import com.arcgismaps.ArcGISEnvironment
import com.esri.arcgismaps.sample.sampleslib.theme.SampleAppTheme
import com.esri.arcgismaps.sample.addbuildingscenelayer.screens.AddBuildingSceneLayerScreen

class MainActivity : ComponentActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// authentication with an API key or named user is
// required to access basemaps and other location services
ArcGISEnvironment.apiKey = ApiKey.create(BuildConfig.ACCESS_TOKEN)

setContent {
SampleAppTheme {
AddBuildingSceneLayerApp()
}
}
}

@Composable
private fun AddBuildingSceneLayerApp() {
Surface(color = MaterialTheme.colorScheme.background) {
AddBuildingSceneLayerScreen(
sampleName = getString(R.string.add_building_scene_layer_app_name)
)
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
/* 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.
*
*/

package com.esri.arcgismaps.sample.addbuildingscenelayer.screens

import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Switch
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.arcgismaps.geometry.Point
import com.arcgismaps.geometry.SpatialReference
import com.arcgismaps.mapping.ArcGISScene
import com.arcgismaps.mapping.ArcGISTiledElevationSource
import com.arcgismaps.mapping.BasemapStyle
import com.arcgismaps.mapping.layers.BuildingSceneLayer
import com.arcgismaps.mapping.layers.buildingscene.BuildingSublayer
import com.arcgismaps.mapping.view.Camera
import com.arcgismaps.mapping.view.SceneViewingMode
import com.arcgismaps.toolkit.geoviewcompose.LocalSceneView
import com.arcgismaps.toolkit.geoviewcompose.LocalSceneViewProxy
Comment on lines +46 to +47
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Libs toml will need to be updated with v.next to allow local builds use LSV.

import com.esri.arcgismaps.sample.sampleslib.components.SampleTopAppBar

/**
* Main screen layout for the sample app
*/
@Composable
fun AddBuildingSceneLayerScreen(sampleName: String) {
// A Boolean value that indicates if the full model of the building scene layer is showing or not
var isFullModel by remember { mutableStateOf(false) }

val elevationSource = remember {
ArcGISTiledElevationSource("https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer")
}

val buildingSceneLayer = remember {
BuildingSceneLayer("https://www.arcgis.com/home/item.html?id=669f6279c579486eb4a0acc7eb59d7ca")
.apply {
// 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.
altitudeOffset = 1.0
}
}

val localSceneViewProxy = remember { LocalSceneViewProxy() }
Comment on lines +58 to +73
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like this sample does not use a view model, if so we should I would recommend remember { mutableStateOf(...) } as needed to allow updates to pass down to the GeoView.


// The overview sublayer which represents the exterior shell of the building.
var overviewSublayer: BuildingSublayer? = null

// The full model sublayer which contains all the features of the building.
var fullModelSublayer: BuildingSublayer? = null

val arcGISScene = remember {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this scene also be a mutable state of if not using a view model?

ArcGISScene(
BasemapStyle.ArcGISTopographic,
SceneViewingMode.Local
).apply {
baseSurface.elevationSources.add(elevationSource)
operationalLayers.add(buildingSceneLayer)
}
}

// set a suitable camera to view the building
LaunchedEffect(Unit) {
arcGISScene.load().onSuccess {
localSceneViewProxy.setViewpointCamera(
Camera(
Point(
x = -13045114.646632874,
y = 4036662.761124578,
z = 511.0,
spatialReference = SpatialReference.webMercator()
),
heading = 343.0,
pitch = 64.0,
roll = 0.0
)
)
}
}

// Get the overview and full model sublayers for the toggle
LaunchedEffect(Unit) {
buildingSceneLayer.load().onSuccess {
val sublayers = buildingSceneLayer.sublayers
overviewSublayer = sublayers.first { it.name == "Overview" }
fullModelSublayer = sublayers.first { it.name == "Full Model" }
}
}

Scaffold(
topBar = { SampleTopAppBar(title = sampleName) },
content = {
Column(
modifier = Modifier
.fillMaxSize()
.padding(it),
) {
LocalSceneView(
modifier = Modifier
.fillMaxSize()
.weight(1f),
localSceneViewProxy = localSceneViewProxy,
scene = arcGISScene,
)
Row(modifier = Modifier.fillMaxWidth(),
horizontalArrangement = Arrangement.End,
verticalAlignment = Alignment.CenterVertically) {
Text(text = "Full Model")
Switch(checked = isFullModel,
onCheckedChange = { isChecked ->
isFullModel = isChecked
fullModelSublayer?.isVisible = isFullModel
overviewSublayer?.isVisible = !isFullModel
},
modifier = Modifier.padding(10.dp))
}
}
}
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<resources>
<string name="add_building_scene_layer_app_name">Add building scene layer</string>
</resources>
Loading