Contents

DirectionalLight

An entity that casts a virtual light in a particular direction.

Declaration

@MainActor @preconcurrency class DirectionalLight

Overview

During an AR session, RealityKit automatically lights your virtual objects to match real-world lighting. You can also explicitly add virtual lights that act upon your virtual content. This is typically most useful outside of an AR session on iOS or macOS, where your RealityViewCameraContent camera property is set to virtual.

A directional light uniformly casts light along its local z-axis—specifically, along [0, 0, -1]. This is equivalent to creating an Entity, and then adding a DirectionalLightComponent to its components set. Use the light’s look(at:from:upVector:relativeTo:) method to aim the light in a particular direction.

You can configure the light’s color and intensity with the component properties in light. You can also control how or if it casts a shadow.

A RealityKit scene can contain up to eight dynamic lights, which are entities that contain a SpotLightComponent, PointLightComponent, or a DirectionalLightComponent. This limit doesn’t include light from image-based lighting.

Topics

Creating a directional light

See Also

Entity compliance