MovableComponent


public final class MovableComponent implements 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 methods

final void

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

final void
addMoveListener(
    @NonNull Executor executor,
    @NonNull MoveListener moveListener
)

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

static final @NonNull MovableComponent
create(
    @NonNull Session session,
    boolean systemMovable,
    boolean scaleInZ,
    @NonNull Set<@NonNull AnchorPlacement> anchorPlacement,
    boolean shouldDisposeParentAnchor
)

Public factory function for creating a MovableComponent.

final @NonNull Dimensions

The current size of the entity, in meters.

boolean

Called when this component is attached to the entity.

void

Called when this component is detached from the entity.

final void

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

final void

The current size of the entity, in meters.

Public methods

addMoveListener

Added in 1.0.0-alpha02
public final void addMoveListener(@NonNull MoveListener moveListener)

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
@NonNull MoveListener moveListener

The move event listener to set.

addMoveListener

Added in 1.0.0-alpha02
public final void addMoveListener(
    @NonNull Executor executor,
    @NonNull MoveListener moveListener
)

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
@NonNull Executor executor

The executor to run the listener on.

@NonNull MoveListener moveListener

The move event listener to set.

create

Added in 1.0.0-alpha02
public static final @NonNull MovableComponent create(
    @NonNull Session session,
    boolean systemMovable,
    boolean scaleInZ,
    @NonNull Set<@NonNull AnchorPlacement> anchorPlacement,
    boolean shouldDisposeParentAnchor
)

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
@NonNull Session session

The Session instance.

boolean systemMovable

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

boolean scaleInZ

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

@NonNull Set<@NonNull AnchorPlacement> anchorPlacement

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.

boolean shouldDisposeParentAnchor

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.

getSize

Added in 1.0.0-alpha02
public final @NonNull Dimensions getSize()

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.

onAttach

public boolean onAttach(@NonNull Entity entity)

Called when this component is attached to the entity.

Parameters
@NonNull Entity entity

Entity this component is being attached to.

Returns
boolean

True if the component can attach to given Entity.

onDetach

public void onDetach(@NonNull Entity entity)

Called when this component is detached from the entity.

Parameters
@NonNull Entity entity

Entity this component is being detached from.

removeMoveListener

Added in 1.0.0-alpha02
public final void removeMoveListener(@NonNull MoveListener moveListener)

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

Parameters
@NonNull MoveListener moveListener

The move event listener to remove.

setSize

Added in 1.0.0-alpha02
public final void setSize(@NonNull Dimensions size)

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.