JxrPlatformAdapter


interface JxrPlatformAdapter


Interface for SceneCore Platform operations. This is not intended to be used by Applications.

Summary

Nested types

Interface for a SceneCore ActivityPanel entity.

Interface for a SceneCore ActivityPose

Interface for a SceneCore activity space.

Interface for a listener which receives changes to the bounds of the primary Activity.

Interface for Anchor entity.

Interface for listening to Anchor state changes.

Specifies the current persistence state of the Anchor.

Interface for listening to Anchor persist state changes.

Specifies the current tracking state of the Anchor.

Interface for an AnchorPlacement.

Interface for a SceneCore AudioTrackExtensionsWrapper

Interface for a SceneCore camera view ActivityPose.

The angles (in radians) representing the sides of the view frustum.

Base interface for all components.

The dimensions of a UI element in meters.

Interface for a SceneCore Entity

Interface for an EXR resource.

Interface for a SceneCore [GltfEntity].

Interface for a glTF resource.

Interface for a SceneCore head ActivityPose.

InputEvent for SceneCore Platform.

Info about the hit result of the ray.

Interface for Input listener.

Component to enable input interactions.

Interface for a SceneCore Entity that only logs the pose.

Interface for a SceneCore MediaPlayerExtensionsWrapper

Component to enable a high level user movement affordance.

MoveEvent for SceneCore Platform.

Interface for MoveEvent listener.

Interface for a SceneCore Panel entity

Interface for the perception space ActivityPose.

The dimensions of a UI element in pixels.

Semantic plane types.

Type of plane based on orientation i.e. Horizontal or Vertical.

Represents a SceneCore PointSourceAttributes

Component to enable pointer capture.

Functional interface for receiving updates about the state of pointer capture.

Ray in 3D Cartesian space.

Component to enable resize semantics.

ResizeEvent for SceneCore Platform.

Interface for ResizeEvent listener.

Interface for a SceneCore resource.

Represents a SceneCore SoundFieldAttributes

Interface for a SceneCore SoundPoolExtensionsWrapper.

Spatial Capabilities for SceneCore Platform.

Interface for updating the background image/geometry and passthrough settings.

Result values for calls to SpatialEnvironment.setPassthroughOpacityPreference

Result values for calls to SpatialEnvironment.setSpatialEnvironmentPreference

A class that represents the user's preferred spatial environment.

Contains the constants used to spatialize audio in SceneCore.

Interface for a surface which images can be rendered into.

Interface for a system-controlled SceneCore Entity that defines its own coordinate space.

Interface for a listener which receives changes to the underlying space.

Public functions

Unit

Adds the given Consumer as a listener to be invoked when this Session's current SpatialCapabilities change. accept will be invoked on the given Executor.

JxrPlatformAdapter.ActivityPanelEntity
createActivityPanelEntity(
    pose: Pose,
    windowBoundsPx: JxrPlatformAdapter.PixelDimensions,
    name: String,
    hostActivity: Activity,
    parent: JxrPlatformAdapter.Entity
)

Factory function to create ActivityPanel to launch/move activity into.

JxrPlatformAdapter.AnchorEntity

A factory function to create an Anchor entity from a androidx.xr.arcore.Anchor.

JxrPlatformAdapter.AnchorEntity
createAnchorEntity(
    bounds: JxrPlatformAdapter.Dimensions,
    planeType: JxrPlatformAdapter.PlaneType,
    planeSemantic: JxrPlatformAdapter.PlaneSemantic,
    searchTimeout: Duration
)

A factory function to create an Anchor entity.

JxrPlatformAdapter.AnchorPlacement

Creates an instance of an AnchorPlacement object.

JxrPlatformAdapter.Entity

A factory function to create a content-less entity.

JxrPlatformAdapter.GltfEntity
createGltfEntity(
    pose: Pose,
    loadedGltf: JxrPlatformAdapter.GltfModelResource,
    parentEntity: JxrPlatformAdapter.Entity?
)

A factory function to create a SceneCore GltfEntity.

JxrPlatformAdapter.InteractableComponent

Create an Interactable component.

JxrPlatformAdapter.LoggingEntity

A function to create a SceneCore Entity

JxrPlatformAdapter.MovableComponent
createMovableComponent(
    systemMovable: Boolean,
    scaleInZ: Boolean,
    anchorPlacement: (Mutable)Set<JxrPlatformAdapter.AnchorPlacement!>,
    shouldDisposeParentAnchor: Boolean
)

Create an instance of [MovableComponent].

JxrPlatformAdapter.PanelEntity
createPanelEntity(
    pose: Pose,
    view: View,
    surfaceDimensionsPx: JxrPlatformAdapter.PixelDimensions,
    dimensions: JxrPlatformAdapter.Dimensions,
    name: String,
    context: Context,
    parent: JxrPlatformAdapter.Entity
)

A factory function to create a platform PanelEntity.

JxrPlatformAdapter.AnchorEntity
createPersistedAnchorEntity(uuid: UUID, searchTimeout: Duration)

A factory function to recreate an Anchor entity which was persisted in a previous session.

JxrPlatformAdapter.PointerCaptureComponent

Create an instance of PointerCaptureComponent.

JxrPlatformAdapter.ResizableComponent

Create an instance of [ResizableComponent].

JxrPlatformAdapter.StereoSurfaceEntity
createStereoSurfaceEntity(
    stereoMode: Int,
    dimensions: JxrPlatformAdapter.Dimensions,
    pose: Pose,
    parentEntity: JxrPlatformAdapter.Entity
)

A factory function for an Entity which displays drawable surfaces.

Unit

Disposes of the resources used by the platform adapter.

JxrPlatformAdapter.ActivitySpace

Returns the Activity Space entity at the root of the scene.

JxrPlatformAdapter.Entity

Returns the entity that represents the ActivitySpace root.

JxrPlatformAdapter.AudioTrackExtensionsWrapper

Returns an [AudioTrackExtensionssWrapper] instance.

JxrPlatformAdapter.CameraViewActivityPose?

Returns the CameraViewActivityPose for the specified camera type or null if it is not ready/available.

JxrPlatformAdapter.HeadActivityPose?

Returns the HeadActivityPose for the Session or null if it is not ready

JxrPlatformAdapter.PanelEntity

Get the PanelEntity associated with the main window for the Activity.

JxrPlatformAdapter.MediaPlayerExtensionsWrapper

Returns a [MediaPlayerExtensionsWrapper] instance.

JxrPlatformAdapter.PerceptionSpaceActivityPose

Returns the PerceptionSpaceActivityPose for the Session.

JxrPlatformAdapter.SoundPoolExtensionsWrapper

Returns a [SoundPoolExtensionsWrapper] instance.

JxrPlatformAdapter.SpatialCapabilities

Return the Spatial Capabilities set that are currently supported by the platform.

JxrPlatformAdapter.SpatialEnvironment

Returns the Environment for the Session.

ListenableFuture<JxrPlatformAdapter.ExrImageResource!>?

Loads an ExrImage for the given asset name from the assets folder.

ListenableFuture<JxrPlatformAdapter.GltfModelResource!>?

Loads glTF Asset for the given asset name from the assets folder.

ListenableFuture<JxrPlatformAdapter.GltfModelResource!>?

Loads glTF Asset for the given asset name from the assets folder using the Split Engine route.

Unit

Releases the given Consumer from receiving updates when the Session's change.

Unit

If the primary Activity for this Session has focus, causes it to be placed in FullSpace Mode.

Unit

If the primary Activity for this Session has focus, causes it to be placed in HomeSpace Mode.

Bundle

Sets the full space mode flag to the given Bundle.

Bundle

Sets the inherit full space mode environment flag to the given Bundle.

Unit
setPreferredAspectRatio(activity: Activity, preferredRatio: Float)

Sets a preferred main panel aspect ratio for home space mode.

Unit

Starts the SceneCore renderer.

Unit

Stops the SceneCore renderer.

Boolean

Unpersist an AnchorEntity.

Public functions

addSpatialCapabilitiesChangedListener

Added in 1.0.0-alpha01
fun addSpatialCapabilitiesChangedListener(
    callbackExecutor: Executor,
    listener: Consumer<JxrPlatformAdapter.SpatialCapabilities!>
): Unit

Adds the given Consumer as a listener to be invoked when this Session's current SpatialCapabilities change. accept will be invoked on the given Executor.

createActivityPanelEntity

Added in 1.0.0-alpha01
fun createActivityPanelEntity(
    pose: Pose,
    windowBoundsPx: JxrPlatformAdapter.PixelDimensions,
    name: String,
    hostActivity: Activity,
    parent: JxrPlatformAdapter.Entity
): JxrPlatformAdapter.ActivityPanelEntity

Factory function to create ActivityPanel to launch/move activity into.

Parameters
pose: Pose

Initial pose of the panel.

windowBoundsPx: JxrPlatformAdapter.PixelDimensions

Boundary for the window

name: String

Name of the panel.

hostActivity: Activity

Activity to host the panel.

parent: JxrPlatformAdapter.Entity

Parent entity.

createAnchorEntity

Added in 1.0.0-alpha01
fun createAnchorEntity(anchor: Anchor): JxrPlatformAdapter.AnchorEntity

A factory function to create an Anchor entity from a androidx.xr.arcore.Anchor.

Parameters
anchor: Anchor

The androidx.xr.arcore.Anchor to create the Anchor entity from.

createAnchorEntity

Added in 1.0.0-alpha01
fun createAnchorEntity(
    bounds: JxrPlatformAdapter.Dimensions,
    planeType: JxrPlatformAdapter.PlaneType,
    planeSemantic: JxrPlatformAdapter.PlaneSemantic,
    searchTimeout: Duration
): JxrPlatformAdapter.AnchorEntity

A factory function to create an Anchor entity.

Parameters
bounds: JxrPlatformAdapter.Dimensions

Bounds for this Anchor.

planeType: JxrPlatformAdapter.PlaneType

Orientation of the plane to which this anchor should attach.

planeSemantic: JxrPlatformAdapter.PlaneSemantic

Semantic type of the plane to which this anchor should attach.

searchTimeout: Duration

How long to search for an anchor. If this is Duration.ZERO, this will search for an anchor indefinitely.

createAnchorPlacementForPlanes

Added in 1.0.0-alpha01
fun createAnchorPlacementForPlanes(
    planeTypeFilter: (Mutable)Set<JxrPlatformAdapter.PlaneType!>,
    planeSemanticFilter: (Mutable)Set<JxrPlatformAdapter.PlaneSemantic!>
): JxrPlatformAdapter.AnchorPlacement

Creates an instance of an AnchorPlacement object.

This can be used in movable components to specify the anchor placement for the entity.

Parameters
planeTypeFilter: (Mutable)Set<JxrPlatformAdapter.PlaneType!>

A set of plane types to filter for.

planeSemanticFilter: (Mutable)Set<JxrPlatformAdapter.PlaneSemantic!>

A set of plane semantics to filter for.

Returns
JxrPlatformAdapter.AnchorPlacement

[AnchorPlacement] instance.

createEntity

Added in 1.0.0-alpha01
fun createEntity(pose: Pose, name: String, parent: JxrPlatformAdapter.Entity): JxrPlatformAdapter.Entity

A factory function to create a content-less entity. This entity is used as a connection point for attaching children entities and managing them (i.e. setPose()) as a group.

Parameters
pose: Pose

Initial pose of the entity.

name: String

Name of the entity.

parent: JxrPlatformAdapter.Entity

Parent entity.

createGltfEntity

Added in 1.0.0-alpha01
fun createGltfEntity(
    pose: Pose,
    loadedGltf: JxrPlatformAdapter.GltfModelResource,
    parentEntity: JxrPlatformAdapter.Entity?
): JxrPlatformAdapter.GltfEntity

A factory function to create a SceneCore GltfEntity. The parent may be the activity space or GltfEntity in the scene.

createInteractableComponent

Added in 1.0.0-alpha01
fun createInteractableComponent(
    executor: Executor,
    listener: JxrPlatformAdapter.InputEventListener
): JxrPlatformAdapter.InteractableComponent

Create an Interactable component.

Parameters
executor: Executor

Executor to use for input callbacks.

listener: JxrPlatformAdapter.InputEventListener

[JxrPlatformAdapter.InputEventListener] for this component.

Returns
JxrPlatformAdapter.InteractableComponent

InteractableComponent instance.

createLoggingEntity

Added in 1.0.0-alpha01
fun createLoggingEntity(pose: Pose): JxrPlatformAdapter.LoggingEntity

A function to create a SceneCore Entity

createMovableComponent

Added in 1.0.0-alpha01
fun createMovableComponent(
    systemMovable: Boolean,
    scaleInZ: Boolean,
    anchorPlacement: (Mutable)Set<JxrPlatformAdapter.AnchorPlacement!>,
    shouldDisposeParentAnchor: Boolean
): JxrPlatformAdapter.MovableComponent

Create an instance of [MovableComponent]. This component allows the user to move the entity.

Parameters
systemMovable: Boolean

A [boolean] which causes the system to automatically apply transform updates to the entity in response to user interaction.

scaleInZ: Boolean

A [boolean] which tells the system to update the scale of the Entity as the user moves it closer and further away. This is mostly useful for Panel auto-rescaling with Distance

anchorPlacement: (Mutable)Set<JxrPlatformAdapter.AnchorPlacement!>

AnchorPlacement information for when to anchor the entity.

shouldDisposeParentAnchor: Boolean

A [boolean] which tells the system to dispose of the parent anchor if that entity was created by the moveable component and is moved off of it.

Returns
JxrPlatformAdapter.MovableComponent

[MovableComponent] instance.

createPanelEntity

Added in 1.0.0-alpha01
fun createPanelEntity(
    pose: Pose,
    view: View,
    surfaceDimensionsPx: JxrPlatformAdapter.PixelDimensions,
    dimensions: JxrPlatformAdapter.Dimensions,
    name: String,
    context: Context,
    parent: JxrPlatformAdapter.Entity
): JxrPlatformAdapter.PanelEntity

A factory function to create a platform PanelEntity. The parent can be any entity.

Parameters
pose: Pose

Initial pose of the panel.

view: View

View inflating this panel.

surfaceDimensionsPx: JxrPlatformAdapter.PixelDimensions

Dimensions for the underlying surface for the given view.

dimensions: JxrPlatformAdapter.Dimensions

Size of the panel in meters.

name: String

Name of the panel.

context: Context

Application Context.

parent: JxrPlatformAdapter.Entity

Parent entity.

createPersistedAnchorEntity

Added in 1.0.0-alpha01
fun createPersistedAnchorEntity(uuid: UUID, searchTimeout: Duration): JxrPlatformAdapter.AnchorEntity

A factory function to recreate an Anchor entity which was persisted in a previous session.

Parameters
uuid: UUID

The UUID of the persisted anchor.

searchTimeout: Duration

How long to search for an anchor. If this is Duration.ZERO, this will search for an anchor indefinitely.

createPointerCaptureComponent

Added in 1.0.0-alpha01
fun createPointerCaptureComponent(
    executor: Executor,
    stateListener: JxrPlatformAdapter.PointerCaptureComponent.StateListener,
    inputListener: JxrPlatformAdapter.InputEventListener
): JxrPlatformAdapter.PointerCaptureComponent

Create an instance of PointerCaptureComponent. This component allows the user to capture and redirect to itself all input that would be received by entities other than the Entity it is attached to and that entity's children.

In order to enable pointer capture, an application must be in full space and the entity it is attached to must be visible.

Attach this component to the entity to enable pointer capture, detach the component to restore normal input flow.

Parameters
executor: Executor

Executor used to propagate state and input events.

stateListener: JxrPlatformAdapter.PointerCaptureComponent.StateListener

Callback for updates to the state of pointer capture. Pointer capture may be temporarily lost by the application for a variety of reasons and this callback will notify of when that happens.

inputListener: JxrPlatformAdapter.InputEventListener

Callback that will receive captured [InputEvent]s

createResizableComponent

Added in 1.0.0-alpha01
fun createResizableComponent(
    minimumSize: JxrPlatformAdapter.Dimensions,
    maximumSize: JxrPlatformAdapter.Dimensions
): JxrPlatformAdapter.ResizableComponent

Create an instance of [ResizableComponent]. This component allows the user to resize the entity.

Parameters
minimumSize: JxrPlatformAdapter.Dimensions

Minimum size constraint.

maximumSize: JxrPlatformAdapter.Dimensions

Maximum size constraint.

Returns
JxrPlatformAdapter.ResizableComponent

[ResizableComponent] instance.

createStereoSurfaceEntity

Added in 1.0.0-alpha01
fun createStereoSurfaceEntity(
    stereoMode: Int,
    dimensions: JxrPlatformAdapter.Dimensions,
    pose: Pose,
    parentEntity: JxrPlatformAdapter.Entity
): JxrPlatformAdapter.StereoSurfaceEntity

A factory function for an Entity which displays drawable surfaces.

dispose

Added in 1.0.0-alpha01
fun dispose(): Unit

Disposes of the resources used by the platform adapter.

getActivitySpace

Added in 1.0.0-alpha01
fun getActivitySpace(): JxrPlatformAdapter.ActivitySpace

Returns the Activity Space entity at the root of the scene.

getActivitySpaceRootImpl

Added in 1.0.0-alpha01
fun getActivitySpaceRootImpl(): JxrPlatformAdapter.Entity

Returns the entity that represents the ActivitySpace root.

SDK's factory methods are expected to use this entity as the default parent for all content entities when no parent is specified.

getAudioTrackExtensionsWrapper

Added in 1.0.0-alpha01
fun getAudioTrackExtensionsWrapper(): JxrPlatformAdapter.AudioTrackExtensionsWrapper

Returns an [AudioTrackExtensionssWrapper] instance.

getCameraViewActivityPose

Added in 1.0.0-alpha01
fun getCameraViewActivityPose(cameraType: Int): JxrPlatformAdapter.CameraViewActivityPose?

Returns the CameraViewActivityPose for the specified camera type or null if it is not ready/available.

getHeadActivityPose

Added in 1.0.0-alpha01
fun getHeadActivityPose(): JxrPlatformAdapter.HeadActivityPose?

Returns the HeadActivityPose for the Session or null if it is not ready

getMainPanelEntity

Added in 1.0.0-alpha01
fun getMainPanelEntity(): JxrPlatformAdapter.PanelEntity

Get the PanelEntity associated with the main window for the Activity.

getMediaPlayerExtensionsWrapper

Added in 1.0.0-alpha01
fun getMediaPlayerExtensionsWrapper(): JxrPlatformAdapter.MediaPlayerExtensionsWrapper

Returns a [MediaPlayerExtensionsWrapper] instance.

getPerceptionSpaceActivityPose

Added in 1.0.0-alpha01
fun getPerceptionSpaceActivityPose(): JxrPlatformAdapter.PerceptionSpaceActivityPose

Returns the PerceptionSpaceActivityPose for the Session.

getSoundPoolExtensionsWrapper

Added in 1.0.0-alpha01
fun getSoundPoolExtensionsWrapper(): JxrPlatformAdapter.SoundPoolExtensionsWrapper

Returns a [SoundPoolExtensionsWrapper] instance.

getSpatialCapabilities

Added in 1.0.0-alpha01
fun getSpatialCapabilities(): JxrPlatformAdapter.SpatialCapabilities

Return the Spatial Capabilities set that are currently supported by the platform.

getSpatialEnvironment

Added in 1.0.0-alpha01
fun getSpatialEnvironment(): JxrPlatformAdapter.SpatialEnvironment

Returns the Environment for the Session.

loadExrImageByAssetName

Added in 1.0.0-alpha01
fun loadExrImageByAssetName(assetName: String): ListenableFuture<JxrPlatformAdapter.ExrImageResource!>?

Loads an ExrImage for the given asset name from the assets folder.

loadGltfByAssetName

Added in 1.0.0-alpha01
fun loadGltfByAssetName(assetName: String): ListenableFuture<JxrPlatformAdapter.GltfModelResource!>?

Loads glTF Asset for the given asset name from the assets folder.

loadGltfByAssetNameSplitEngine

Added in 1.0.0-alpha01
fun loadGltfByAssetNameSplitEngine(assetName: String): ListenableFuture<JxrPlatformAdapter.GltfModelResource!>?

Loads glTF Asset for the given asset name from the assets folder using the Split Engine route. The future returned by this method will fire listeners on the UI thread if Runnable::run is supplied.

removeSpatialCapabilitiesChangedListener

Added in 1.0.0-alpha01
fun removeSpatialCapabilitiesChangedListener(
    listener: Consumer<JxrPlatformAdapter.SpatialCapabilities!>
): Unit

Releases the given Consumer from receiving updates when the Session's change.

requestFullSpaceMode

Added in 1.0.0-alpha01
fun requestFullSpaceMode(): Unit

If the primary Activity for this Session has focus, causes it to be placed in FullSpace Mode. Otherwise, this call does nothing.

requestHomeSpaceMode

Added in 1.0.0-alpha01
fun requestHomeSpaceMode(): Unit

If the primary Activity for this Session has focus, causes it to be placed in HomeSpace Mode. Otherwise, this call does nothing.

setFullSpaceMode

Added in 1.0.0-alpha01
fun setFullSpaceMode(bundle: Bundle): Bundle

Sets the full space mode flag to the given Bundle.

The Bundle then could be used to launch an Activity with requesting to enter full space mode through startActivity. If there's a bundle used for customizing how the Activity should be started by ActivityOptions.toBundle or androidx.core.app.ActivityOptionsCompat.toBundle, it's suggested to use the bundle to call this method.

The flag will be ignored when no Intent.FLAG_ACTIVITY_NEW_TASK is set in the bundle, or it is not started from a focused Activity context.

This flag is also ignored when the android.window.PROPERTY_XR_ACTIVITY_START_MODE property is set to a value other than XR_ACTIVITY_START_MODE_UNDEFINED in the AndroidManifest.xml file for the activity being launched.

Parameters
bundle: Bundle

the input bundle to set with the full space mode flag.

Returns
Bundle

the input bundle with the full space mode flag set.

setFullSpaceModeWithEnvironmentInherited

Added in 1.0.0-alpha01
fun setFullSpaceModeWithEnvironmentInherited(bundle: Bundle): Bundle

Sets the inherit full space mode environment flag to the given Bundle.

The Bundle then could be used to launch an Activity with requesting to enter full space mode while inherit the existing environment through startActivity. If there's a bundle used for customizing how the Activity should be started by ActivityOptions.toBundle or , it's suggested to use the bundle to call this method.

When launched, the activity will be in full space mode and also inherits the environment from the launching activity. If the inherited environment needs to be animated, the launching activity has to continue updating the environment even after the activity is put into the stopped state.

The flag will be ignored when no Intent.FLAG_ACTIVITY_NEW_TASK is set in the intent, or it is not started from a focused Activity context.

The flag will also be ignored when there is no environment to inherit or the activity has its own environment set already.

This flag is ignored too when the android.window.PROPERTY_XR_ACTIVITY_START_MODE property is set to a value other than XR_ACTIVITY_START_MODE_UNDEFINED in the AndroidManifest.xml file for the activity being launched.

For security reasons, Z testing for the new activity is disabled, and the activity is always drawn on top of the inherited environment. Because Z testing is disabled, the activity should not spatialize itself, and should not curve its panel too much either.

Parameters
bundle: Bundle

the input bundle to set with the inherit full space mode environment flag.

Returns
Bundle

the input bundle with the inherit full space mode flag set.

setPreferredAspectRatio

Added in 1.0.0-alpha01
fun setPreferredAspectRatio(activity: Activity, preferredRatio: Float): Unit

Sets a preferred main panel aspect ratio for home space mode.

The ratio is only applied to the activity. If the activity launches another activity in the same task, the ratio is not applied to the new activity. Also, while the activity is in full space mode, the preference is temporarily removed.

Parameters
activity: Activity

the activity to set the preference.

preferredRatio: Float

the aspect ratio determined by taking the panel's width over its height. A value <= 0.0f means there are no preferences.

startRenderer

Added in 1.0.0-alpha01
fun startRenderer(): Unit

Starts the SceneCore renderer.

stopRenderer

Added in 1.0.0-alpha01
fun stopRenderer(): Unit

Stops the SceneCore renderer.

unpersistAnchor

Added in 1.0.0-alpha01
fun unpersistAnchor(uuid: UUID): Boolean

Unpersist an AnchorEntity. It will clean up the data in the storage that is required to retrieve the anchor. Returns whether the anchor was successfully unpersisted.

Parameters
uuid: UUID

UUID of the anchor to unpersist.