Skip to main content

Class: UX

Defined in: src/ux/UX.ts:10

UX manages the user experience (UX) state for an interactive object in the scene. It tracks interaction states like hover, selection, and dragging for multiple controllers.

Constructors

Constructor

new UX(parent): UX

Defined in: src/ux/UX.ts:91

Parameters

parent

Object3D

The script or object that owns this UX instance.

Returns

UX

Properties

activeDragged

activeDragged: boolean[] = []

Defined in: src/ux/UX.ts:54

An array tracking the drag state for each controller.


distances

distances: number[] = []

Defined in: src/ux/UX.ts:67

An array storing the distance of the last intersection for each controller.


draggable

draggable: boolean = false

Defined in: src/ux/UX.ts:19

Indicates if the parent object can be dragged.


hovered

hovered: boolean[] = []

Defined in: src/ux/UX.ts:43

An array tracking the hover state for each controller. hovered[i] is true if controller i is hovering over the object.


initialDistance?

optional initialDistance: number

Defined in: src/ux/UX.ts:86

The initial distance from the controller to the object at the start of a drag for computing the relative dragging distances and angles.


initialPosition

initialPosition: Vector3

Defined in: src/ux/UX.ts:80

The initial position of the object when a drag operation begins.


parent

parent: Object3D<Object3DEventMap>

Defined in: src/ux/UX.ts:14

The object this UX state manager is attached to.


positions

positions: Vector3[] = []

Defined in: src/ux/UX.ts:62

An array storing the 3D position of the last intersection for each controller.


selectable

selectable: boolean = false

Defined in: src/ux/UX.ts:24

Indicates if the parent object can be selected.


selected

selected: boolean[] = []

Defined in: src/ux/UX.ts:37

An array tracking the selection state for each controller. selected[i] is true if controller i is selecting the object.


touchable

touchable: boolean = false

Defined in: src/ux/UX.ts:29

Indicates if the parent object can be touched.


touched

touched: boolean[] = []

Defined in: src/ux/UX.ts:49

An array tracking the touch state for each controller. touched[i] is true if controller i is touching over the object.


uvs

uvs: Vector2[] = []

Defined in: src/ux/UX.ts:73

An array storing the UV coordinates of the last intersection for each controller.

Methods

getPrimaryTwoControllerIds()

getPrimaryTwoControllerIds(): number[]

Defined in: src/ux/UX.ts:182

Gets the IDs of up to two controllers that are currently hovering over the parent object, always returning a two-element array. This is useful for shaders or components like Panels that expect a fixed number of interaction points.

Returns

number[]

A fixed-size two-element array. Each element is either a controller ID (e.g., 0, 1) or null.


initializeVariablesForId()

initializeVariablesForId(id): void

Defined in: src/ux/UX.ts:151

Ensures that the internal arrays for tracking states are large enough to accommodate a given controller ID.

Parameters

id

number

The controller ID to ensure exists.

Returns

void


isDragging()

isDragging(): boolean

Defined in: src/ux/UX.ts:112

Checks if the object is currently being dragged by any controller.

Returns

boolean


isHovered()

isHovered(): boolean

Defined in: src/ux/UX.ts:98

Checks if the object is currently being hovered by any controller.

Returns

boolean


isSelected()

isSelected(): boolean

Defined in: src/ux/UX.ts:105

Checks if the object is currently being selected by any controller.

Returns

boolean


reset()

reset(): void

Defined in: src/ux/UX.ts:166

Resets the hover and selection states for all controllers. This is typically called at the beginning of each frame.

Returns

void


update()

update(controller, intersection): void

Defined in: src/ux/UX.ts:124

Updates the interaction state for a specific controller based on a new intersection. This is internally called by the core input system when a raycast hits the parent object.

Parameters

controller

Object3D

The controller performing the interaction.

intersection

Intersection

The raycast intersection data.

Returns

void