> For the complete documentation index, see [llms.txt](https://docs.mapbox.com/android/maps/llms.txt)

# Display 3D buildings with 3D lights

![Extrude the building layer in the Mapbox Standard style and set up the light position.](https://docs.mapbox.com/android/assets/ideal-img/maps-examples-display-3d-buildings-with-3d-lights.ea43c41.480.png)

This example demonstrates how add lights to a 3d map with the Mapbox SDK for Android. The code below creates an [`ambientLight`](https://docs.mapbox.com/android/maps/api/latest/mapbox-maps-android/com.mapbox.maps.extension.style.light.generated/-ambient-light/) with white hue and an intensity of 0.5, as well as a [`directionalLight`](https://docs.mapbox.com/android/maps/api/latest/mapbox-maps-android/com.mapbox.maps.extension.style.light.generated/-directional-light/) with a yellow hue, an intensity of 0.9, and enables shadows pointed at an angle of 15 degrees.

Once the lights are created, they are then applied to the map style using the [`setLight`](https://docs.mapbox.com/android/maps/api/latest/mapbox-maps-android/com.mapbox.maps.extension.style.light/set-light.html) method. The example also includes functionality to interact with the lights dynamically. Clicking the "fabLightColor" button toggles the ambient light's color between white and red, while clicking the "fabLightPosition" button adjusts the direction of the directional light by increments of 5 degrees within a range of 90 degrees.

> **Note: Android Examples App Available**
> 
> This example code is part of the **Maps SDK for Android Examples App**, a working Android project [available on GitHub](https://github.com/mapbox/mapbox-maps-android/tree/v11.33.0/). Android developers are encouraged to run the examples app locally to interact with this example in an emulator and explore other features of the Maps SDK.
> 
> See our [Run the Maps SDK for Android Examples App](https://docs.mapbox.com/help/tutorials/maps-sdk-android-examples-app/) tutorial for step-by-step instructions.

**Kotlin**

Title: `Lights3DActivity.kt`

[View on GitHub](https://github.com/mapbox/mapbox-maps-android/blob/v11.33.0/app/src/main/java/com/mapbox/maps/testapp/examples/terrain3D/Lights3DActivity.kt)

```kt
package com.mapbox.maps.testapp.examples.terrain3D

import android.graphics.Color
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.mapbox.geojson.Point
import com.mapbox.maps.CameraOptions
import com.mapbox.maps.Style
import com.mapbox.maps.extension.style.light.generated.ambientLight
import com.mapbox.maps.extension.style.light.generated.directionalLight
import com.mapbox.maps.extension.style.light.setLight
import com.mapbox.maps.testapp.databinding.ActivityFillExtrusionBinding

/**
 * Extrude the building layer in the Mapbox Standard style
 * and set up the light position.
 */
class Lights3DActivity : AppCompatActivity() {

  private var isRedColor: Boolean = false
  private lateinit var binding: ActivityFillExtrusionBinding

  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    binding = ActivityFillExtrusionBinding.inflate(layoutInflater)
    setContentView(binding.root)
    val mapboxMap = binding.mapView.mapboxMap
    mapboxMap.setCamera(
      CameraOptions.Builder()
        .center(Point.fromLngLat(24.943849, 60.171924))
        .bearing(-17.6)
        .pitch(45.0)
        .zoom(16.0)
        .build()
    )

    mapboxMap.loadStyle(
      Style.STANDARD
    ) { style ->
      setupLights3D(style)
    }
  }

  private fun setupLights3D(style: Style) {
    // setup 3d light
    val ambientLight = ambientLight(AMBIENT_LIGHT_ID) {
      color(Color.WHITE)
      intensity(0.5)
    }
    val directionalLight = directionalLight(DIRECTIONAL_LIGHT_ID) {
      color(Color.YELLOW)
      intensity(0.9)
      castShadows(true)
      direction(listOf(0.0, 15.0))
    }
    style.setLight(
      ambientLight,
      directionalLight,
    )
    // change color on fab click
    binding.fabLightColor.setOnClickListener {
      isRedColor = !isRedColor
      if (isRedColor) {
        ambientLight.color(Color.RED)
      } else {
        ambientLight.color(Color.WHITE)
      }
    }

    binding.fabLightPosition.setOnClickListener {
      directionalLight.direction(listOf(0.0, (directionalLight.direction!![1] + 5.0) % 90.0))
    }
  }

  private companion object {
    private const val AMBIENT_LIGHT_ID = "ambient_id"
    private const val DIRECTIONAL_LIGHT_ID = "directional_id"
  }
}
```