View on GitHub Sample viewer app

Show realistic lighting and shadows for the time of day.

Image of realistic lighting and shadows

Use case

You can use realistic lighting to evaluate the shadow impact of buildings and utility infrastructure on the surrounding community. This could be useful for civil engineers and urban planners, or for events management assessing the impact of building shadows during an outdoor event.

How to use the sample

Select one of the three available lighting options to display that lighting effect. Adjust the slider to show the lighting effect for a particular time of day. The 3D buildings will display shadows when “Sun light with shadows” is selected.

How it works

  1. Create an ArcGISScene and display it in a SceneView.
  2. Create a Calendar to define the time of day.
  3. Set the sun time to that calendar with sceneView.setSunTime(calendar).
  4. Set the LightingMode of the scene view to NO_LIGHT, LIGHT, or LIGHT_AND_SHADOWS with sceneView.setSunLighting(LightingMode).

Relevant API

  • ArcGISScene
  • LightingMode
  • SceneView.setSunLighting
  • SceneView.setSunTime

Tags

3D, lighting, realism, realistic, rendering, shadows, sun, time

Sample Code

module-info.java module-info.java RealisticLightingAndShadowsController.java RealisticLightingAndShadowsSample.java
/*
* Copyright 2022 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.
*/
module com.esri.samples.realistic_lighting_and_shadows {
// require ArcGIS Maps SDK for Java module
requires com.esri.arcgisruntime;
// handle SLF4J http://www.slf4j.org/codes.html#StaticLoggerBinder
requires org.slf4j.nop;
// require JavaFX modules that the application uses
requires javafx.graphics;
requires javafx.controls;
requires javafx.fxml;
// make all @FXML annotated objects reflectively accessible to the javafx.fxml module
opens com.esri.samples.realistic_lighting_and_shadows to javafx.fxml;
exports com.esri.samples.realistic_lighting_and_shadows;
}