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() )

This modifier might not work as expected when used on content within a androidx.xr.compose.spatial.FollowingSubspace.

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.

Content updated: