MovableComponent


class MovableComponent : Component


This Component can be attached to a single instance of an Entity. When attached, this Component will enable the user to translate the Entity by pointing and dragging on it.

This component cannot be attached to an AnchorEntity or to the ActivitySpace. Calling Entity.addComponent to an Entity with these types will return false.

NOTE: This Component is currently unsupported on GltfModelEntity.

Summary

Public companion functions

MovableComponent
createAnchorable(
    session: Session,
    anchorPlacement: Set<AnchorPlacement>,
    disposeParentOnReAnchor: Boolean
)

Public factory function for creating a MovableComponent.

MovableComponent
createCustomMovable(
    session: Session,
    scaleInZ: Boolean,
    executor: Executor?,
    entityMoveListener: EntityMoveListener
)

Public factory function for creating a MovableComponent.

MovableComponent
createSystemMovable(session: Session, scaleInZ: Boolean)

Public factory function for creating a MovableComponent.

Public functions

Unit
addMoveListener(entityMoveListener: EntityMoveListener)

Adds a listener to the set of active listeners for the move events.

Unit
addMoveListener(
    executor: Executor,
    entityMoveListener: EntityMoveListener
)

Adds a listener to the set of active listeners for the move events.

open Boolean
onAttach(entity: Entity)

Called by an Entity when it attempts to add this Component to itself.

open Unit
onDetach(entity: Entity)

Called by an Entity when it attempts to detach this Component from itself.

Unit

Removes a listener from the set of active listeners for the move events.

Public properties

FloatSize3d

The size of the move affordance in meters.

Public companion functions

createAnchorable

Added in 1.0.0-alpha05
fun createAnchorable(
    session: Session,
    anchorPlacement: Set<AnchorPlacement> = setOf(AnchorPlacement.createForPlanes()),
    disposeParentOnReAnchor: Boolean = true
): MovableComponent

Public factory function for creating a MovableComponent.

This Component can be attached to a single instance of an Entity. When attached, this Component will enable the user to translate the Entity by pointing and dragging on it.

When created with this function the MovableComponent will move and potentially Anchor the Entity. When anchored a new AnchorEntity will be created and set as the parent of the Entity. If the entity is moved off of a created AnchorEntity it will be reparented to the ActivitySpace. An EntityMoveListener can be attached to receive callbacks when the Entity is being moved and to see if it was reparented to an AnchorEntity.

This component cannot be attached to an AnchorEntity or to the ActivitySpace. Calling Entity.addComponent to an Entity with these types will return false.

Parameters
session: Session

The Session instance.

anchorPlacement: Set<AnchorPlacement> = setOf(AnchorPlacement.createForPlanes())

A Set containing different AnchorPlacement for how to anchor the Entity with a MovableComponent. When empty this Entity will not be anchored.

disposeParentOnReAnchor: Boolean = true

A Boolean, which if set to true, when an Entity is moved off of an AnchorEntity that was created by the underlying MovableComponent, and the AnchorEntity has no other children, the AnchorEntity will be disposed, and the underlying Anchor will be detached.

Returns
MovableComponent

MovableComponent instance.

Throws
kotlin.IllegalArgumentException

if created with an Empty Set of for anchorPlacement

createCustomMovable

Added in 1.0.0-alpha05
fun createCustomMovable(
    session: Session,
    scaleInZ: Boolean,
    executor: Executor?,
    entityMoveListener: EntityMoveListener
): MovableComponent

Public factory function for creating a MovableComponent.

This Component can be attached to a single instance of an Entity. When attached, this Component will enable the user to translate the Entity by pointing and dragging on it.

When created with this function the MovableComponent will not move or rescale the Entity but it could be done using the EntityMoveListener.onMoveUpdate callback.

This component cannot be attached to an AnchorEntity or to the ActivitySpace. Calling Entity.addComponent to an Entity with these types will return false.

Parameters
session: Session

The Session instance.

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.

executor: Executor?

The executor to run the listener on. If set to null, the listener will be invoked on the main thread.

entityMoveListener: EntityMoveListener

A move event listener for the event. The application should set the entity position and scale as desired using Entity.setPose and Entity.setScale in the EntityMoveListener.onMoveUpdate callback. To have the system do this movement use createSystemMovable or createAnchorable.

Returns
MovableComponent

MovableComponent instance.

createSystemMovable

Added in 1.0.0-alpha05
fun createSystemMovable(session: Session, scaleInZ: Boolean = true): MovableComponent

Public factory function for creating a MovableComponent.

This Component can be attached to a single instance of an Entity. When attached, this Component will enable the user to translate the Entity by pointing and dragging on it.

When created with this function the MovableComponent will move and rescale the Entity. EntityMoveListener can be attached to received callbacks when the Entity is being moved.

This component cannot be attached to an AnchorEntity or to the ActivitySpace. Calling Entity.addComponent to an Entity with these types will return false.

Parameters
session: Session

The Session instance.

scaleInZ: Boolean = true

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.

Returns
MovableComponent

MovableComponent instance.

Public functions

addMoveListener

Added in 1.0.0-alpha05
fun addMoveListener(entityMoveListener: EntityMoveListener): Unit

Adds a listener to the set of active listeners for the move events. The listener will be invoked regardless of whether the Entity is being moved by the system or the user.

The listener is invoked on the main thread.

Parameters
entityMoveListener: EntityMoveListener

The move event listener to set.

addMoveListener

Added in 1.0.0-alpha05
fun addMoveListener(
    executor: Executor,
    entityMoveListener: EntityMoveListener
): Unit

Adds a listener to the set of active listeners for the move events. The listener will be invoked regardless of whether the Entity is being moved by the system or the user.

The listener is invoked on the provided Executor. If the app intends to modify the UI elements/views during the callback, the app should provide the thread executor that is appropriate for the UI operations. For example, if the app is using the main thread to render the UI, the app should provide the main thread (Looper.getMainLooper()) executor. If the app is using a separate thread to render the UI, the app should provide the executor for that thread.

Parameters
executor: Executor

The executor to run the listener on.

entityMoveListener: EntityMoveListener

The move event listener to set.

onAttach

Added in 1.0.0-alpha05
open fun onAttach(entity: Entity): Boolean

Called by an Entity when it attempts to add this Component to itself.

This method is restricted because it is only called from Entity.addComponent.

Parameters
entity: Entity

Entity to which this Component was attached.

Returns
Boolean

True if the Component was attached to the given Entity. False if the Entity did not support having this Component attached.

onDetach

Added in 1.0.0-alpha05
open fun onDetach(entity: Entity): Unit

Called by an Entity when it attempts to detach this Component from itself.

This method is restricted because it is only called from Entity.removeComponent.

Parameters
entity: Entity

Entity from which this Component was detached.

removeMoveListener

Added in 1.0.0-alpha05
fun removeMoveListener(entityMoveListener: EntityMoveListener): Unit

Removes a listener from the set of active listeners for the move events.

Parameters
entityMoveListener: EntityMoveListener

The move event listener to remove.

Public properties

size

Added in 1.0.0-alpha05
var sizeFloatSize3d

The size of the move affordance in meters. This property determines the size of the bounding box that is used to draw the draggable move affordances around the Entity. This property can be modified if the move affordance needs to be larger or smaller than the Entity itself.