Class: FreestandingSlider
Defined in: src/ui/interaction/FreestandingSlider.ts:17
A non-visual helper class for calculating a slider value based on a controller's movement relative to an initial pose. It can derive the value from either positional (for XR hands/controllers) or rotational (for mouse) input, making it a flexible tool for creating virtual sliders without a visible UI element.
Constructors
Constructor
new FreestandingSlider(
startingValue
,minValue
,maxValue
,scale
,rotationScale?
):FreestandingSlider
Defined in: src/ui/interaction/FreestandingSlider.ts:25
Create a freestanding slider object.
Parameters
startingValue
number
= 0.0
minValue
number
= 0.0
maxValue
number
= 1.0
scale
number
= 1.0
rotationScale?
number
Returns
FreestandingSlider
Properties
initialPosition
initialPosition:
Vector3
Defined in: src/ui/interaction/FreestandingSlider.ts:18
initialRotationInverse
initialRotationInverse:
Quaternion
Defined in: src/ui/interaction/FreestandingSlider.ts:19
maxValue
maxValue:
number
=1.0
Defined in: src/ui/interaction/FreestandingSlider.ts:26
minValue
minValue:
number
=0.0
Defined in: src/ui/interaction/FreestandingSlider.ts:26
rotationScale
rotationScale:
number
Defined in: src/ui/interaction/FreestandingSlider.ts:20
scale
scale:
number
=1.0
Defined in: src/ui/interaction/FreestandingSlider.ts:27
startingValue
startingValue:
number
=0.0
Defined in: src/ui/interaction/FreestandingSlider.ts:26
Methods
getValue()
getValue(
position
):number
Defined in: src/ui/interaction/FreestandingSlider.ts:56
Calculates the slider value based on a new world position.
Parameters
position
The current world position of the input source.
Returns
number
The calculated slider value, clamped within the min/max range.
getValueFromController()
getValueFromController(
controller
):number
Defined in: src/ui/interaction/FreestandingSlider.ts:85
A polymorphic method that automatically chooses the correct calculation (positional or rotational) based on the controller type.
Parameters
controller
The controller providing the input.
Returns
number
The calculated slider value.
getValueFromRotation()
getValueFromRotation(
rotation
):number
Defined in: src/ui/interaction/FreestandingSlider.ts:71
Calculates the slider value based on a new world rotation (for mouse input).
Parameters
rotation
The current world rotation of the input source.
Returns
number
The calculated slider value, clamped within the min/max range.
setInitialPose()
setInitialPose(
position
,rotation
):void
Defined in: src/ui/interaction/FreestandingSlider.ts:38
Captures the initial position and rotation to serve as the reference point for the gesture.
Parameters
position
The starting world position.
rotation
The starting world rotation.
Returns
void
setInitialPoseFromController()
setInitialPoseFromController(
controller
):void
Defined in: src/ui/interaction/FreestandingSlider.ts:47
A convenience method to capture the initial pose from a controller object.
Parameters
controller
The controller to use as the reference.
Returns
void
updateValue()
updateValue(
value
):void
Defined in: src/ui/interaction/FreestandingSlider.ts:95
Updates the starting value, typically after a gesture has ended.
Parameters
value
number
The new starting value for the next gesture.
Returns
void