FollowMode

@ExperimentalFollowingSubspaceApi
abstract class FollowMode


A FollowMode controls the motion of content as it is following another target. Currently, the options include "soft", which gradually catches up to the target and "snap", which does not continuously follow the target.

Summary

Public companion functions

FollowMode
snap(dimensions: TrackedDimensions)

Places content once based on the target's initial pose and does not follow subsequent movements.

FollowMode
soft(durationMs: @IntRange(from = 100) Int, dimensions: TrackedDimensions)

This function is deprecated. durationMs is deprecated as follow motion is now based on exponential decay.

FollowMode
soft(
    dimensions: TrackedDimensions,
    halfLifeMillis: @IntRange(from = 1) Long,
    startDelay: @IntRange(from = 0) Long,
    startThresholds: FollowThresholds
)

Creates a mode where the content smoothly animates to follow the target's movements.

FollowMode
tight(dimensions: TrackedDimensions)

Follows the target as closely as possible.

Public companion functions

snap

Added in 1.0.0-beta02
fun snap(dimensions: TrackedDimensions = TrackedDimensions.All): FollowMode

Places content once based on the target's initial pose and does not follow subsequent movements.

Parameters
dimensions: TrackedDimensions = TrackedDimensions.All

A set of boolean flags which determine the dimensions of movement that are tracked. By default, all dimensions are tracked.

soft

Added in 1.0.0-beta02
Deprecated in 1.0.0-beta02
fun soft(
    durationMs: @IntRange(from = 100) Int,
    dimensions: TrackedDimensions = TrackedDimensions.All
): FollowMode

Creates a mode where the content smoothly animates to follow the target's movements.

Parameters
durationMs: @IntRange(from = 100) Int

Amount of milliseconds it takes for the content to catch up to the user.

dimensions: TrackedDimensions = TrackedDimensions.All

A set of boolean flags which determine the dimensions of movement that are tracked. By default, all dimensions are tracked.

Returns
FollowMode

A FollowMode instance configured for soft following.

soft

Added in 1.0.0-beta02
fun soft(
    dimensions: TrackedDimensions = TrackedDimensions.All,
    halfLifeMillis: @IntRange(from = 1) Long = SoftFollowMode.DEFAULT_HALF_LIFE_MILLIS,
    startDelay: @IntRange(from = 0) Long = SoftFollowMode.DEFAULT_START_DELAY,
    startThresholds: FollowThresholds = SoftFollowMode.DEFAULT_START_THRESHOLDS
): FollowMode

Creates a mode where the content smoothly animates to follow the target's movements.

This mode is driven by a first-order exponential decay model, which smoothly decelerates the trailing entity as it approaches the target.

Parameters
dimensions: TrackedDimensions = TrackedDimensions.All

A set of boolean flags which determine the dimensions of movement that are tracked. Defaults to TrackedDimensions.All.

halfLifeMillis: @IntRange(from = 1) Long = SoftFollowMode.DEFAULT_HALF_LIFE_MILLIS

Time in milliseconds it takes for the content to cover half the distance to the target. Defaults to 175 milliseconds.

startDelay: @IntRange(from = 0) Long = SoftFollowMode.DEFAULT_START_DELAY

Time in milliseconds to wait before starting the follow movement. Defaults to 200 milliseconds.

startThresholds: FollowThresholds = SoftFollowMode.DEFAULT_START_THRESHOLDS

A set of thresholds that must be exceeded before movement starts. Defaults to 0.2 meters of translation and 16 degrees of pitch, 24 degrees of yaw, and 20 degrees of roll.

Returns
FollowMode

A FollowMode instance configured for soft following.

tight

Added in 1.0.0-beta02
fun tight(dimensions: TrackedDimensions = TrackedDimensions.All): FollowMode

Follows the target as closely as possible.

In contrast to soft, where the content lags behind the target, tight follow matches the target's movement instantly.

Parameters
dimensions: TrackedDimensions = TrackedDimensions.All

A set of boolean flags which determine the dimensions of movement that are tracked. By default, all dimensions are tracked.

Protected properties

dispatcherOverride

Added in 1.0.0-beta02
protected val dispatcherOverride: CoroutineDispatcher