借助 ARCore for Jetpack XR,应用可以使用低级场景理解原语和运动跟踪功能,实现基本的增强现实 (AR) 概念。在构建 AR 体验时,如果您需要使用平面数据或将内容锚定到空间中的固定位置,请使用 ARCore for Jetpack XR。
访问 Session
使用 ARCore for Jetpack XR 时,必须创建 Session
。
将 Jetpack Compose 用于 XR 时,请使用 LocalSession
访问为您创建的会话。
配置 Session
某些功能可能默认处于停用状态,必须进行配置才能正常运行。如需配置会话,请使用 configure()
并指定 Session
所需的配置选项。例如,如需启用手部跟踪,请将 HandTrackingMode
设置为 HandTrackingMode.BOTH
模式:
val newConfig = session.config.copy( handTracking = Config.HandTrackingMode.BOTH ) when (val result = session.configure(newConfig)) { is SessionConfigureConfigurationNotSupported -> TODO(/* Some combinations of configurations are not valid. Handle this failure case. */) is SessionConfigureSuccess -> TODO(/* Success! */) else -> TODO(/* A different unhandled exception was thrown. */) }