MovableComponent


class MovableComponent : Component


Allows users to interactively move the Entity. This component can be attached to a single instance of any PanelEntity.

NOTE: This Component is currently unsupported on GltfModelEntity.

Summary

Public companion functions

MovableComponent
create(
    session: Session,
    systemMovable: Boolean,
    scaleInZ: Boolean,
    anchorPlacement: Set<AnchorPlacement>,
    shouldDisposeParentAnchor: Boolean
)

Public factory function for creating a MovableComponent.

Public functions

Unit

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

Unit
addMoveListener(executor: Executor, moveListener: MoveListener)

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

open Boolean
onAttach(entity: Entity)

Called when this component is attached to the entity.

open Unit
onDetach(entity: Entity)

Called when this component is detached from the entity.

Unit

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

Public properties

Dimensions

The current size of the entity, in meters.

Public companion functions

create

Added in 1.0.0-alpha02
fun create(
    session: Session,
    systemMovable: Boolean = true,
    scaleInZ: Boolean = true,
    anchorPlacement: Set<AnchorPlacement> = emptySet(),
    shouldDisposeParentAnchor: Boolean = true
): MovableComponent

Public factory function for creating a MovableComponent. This component can be attached to a single instance of any non-Anchor Entity.

When attached, this Component will enable the user to translate the Entity by pointing and dragging on it.

Parameters
session: Session

The Session instance.

systemMovable: Boolean = true

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

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

anchorPlacement: Set<AnchorPlacement> = emptySet()

A Set containing different AnchorPlacement for how to anchor the Entity movable component. If this is not empty the movement semantics will be slightly different from the system as it will add the ability to anchor to nearby planes.

shouldDisposeParentAnchor: 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.

Public functions

addMoveListener

Added in 1.0.0-alpha02
fun addMoveListener(moveListener: MoveListener): 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
moveListener: MoveListener

The move event listener to set.

addMoveListener

Added in 1.0.0-alpha02
fun addMoveListener(executor: Executor, moveListener: MoveListener): 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.

moveListener: MoveListener

The move event listener to set.

onAttach

open fun onAttach(entity: Entity): Boolean

Called when this component is attached to the entity.

Parameters
entity: Entity

Entity this component is being attached to.

Returns
Boolean

True if the component can attach to given Entity.

onDetach

open fun onDetach(entity: Entity): Unit

Called when this component is detached from the entity.

Parameters
entity: Entity

Entity this component is being detached from.

removeMoveListener

Added in 1.0.0-alpha02
fun removeMoveListener(moveListener: MoveListener): Unit

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

Parameters
moveListener: MoveListener

The move event listener to remove.

Public properties

size

Added in 1.0.0-alpha02
var sizeDimensions

The current size of the entity, in meters. The size of the entity determines the size of the bounding box that is used to draw the draggable move affordances around the entity.