Function

rotateToLookAtUser

A SubspaceModifier that continuously rotates content so that it faces the user at all times.

rotateToLookAtUser

Source set: Android
public fun SubspaceModifier.rotateToLookAtUser(
    isYawUpdateEnabled: Boolean = true,
    isPitchUpdateEnabled: Boolean = true,
    pitchLimits: PitchLimits = PitchLimits.FullRange,
): SubspaceModifier

A SubspaceModifier that continuously rotates content so that it faces the user at all times.

A user of this API should configure the activity's Session object with DeviceTrackingMode.SPATIAL which requires android.permission.HEAD_TRACKING Android permission be granted by the calling application. session.configure( config = Config.Builder(session.config).setDeviceTracking(DeviceTrackingMode.SPATIAL).build() )

The preceding rotate modifiers will be disregarded because this modifier will override them. But the rotate after the rotateToLookAtUser modifier will be respected.

To achieve a "billboard" effect—where the content rotates to face the user on the Y-axis while remaining upright and aligned with gravity—combine this with gravityAligned.

Parameters

isYawUpdateEnabled Whether to update the Yaw (Y-axis rotation) to track the user. If false, yaw tracking is disabled and the content retains the Y-axis rotation specified by the layout and preceding modifiers.
isPitchUpdateEnabled Whether to update the Pitch (X-axis rotation) to track the user. If false, pitch tracking is disabled and the content retains the X-axis rotation specified by the layout and preceding modifiers.
pitchLimits The limits for the Pitch (X-axis rotation) to track the user. Defaults to PitchLimits.FullRange. This parameter is ignored if isPitchUpdateEnabled is false.
Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: