@ue-too/board / RotateControlStateMachine
Class: RotateControlStateMachine
Defined in: packages/board/src/camera/camera-mux/animation-and-lock/rotation-control-state-machine.ts:128
State machine controlling rotation input flow and animations.
Remarks
This state machine manages the lifecycle of rotation operations:
- User input handling: Accepts or blocks user rotation gestures based on state
- Animation control: Manages smooth rotate-to animations
- Object tracking: Supports locking camera to follow objects with rotation
State transitions:
ACCEPTING_USER_INPUT→TRANSITION: Start animation (initateTransition)ACCEPTING_USER_INPUT→LOCKED_ON_OBJECT: Lock to object (lockedOnObjectRotate...)TRANSITION→ACCEPTING_USER_INPUT: User input interrupts animationLOCKED_ON_OBJECT→ACCEPTING_USER_INPUT: Unlock (unlockevent)
Helper methods simplify event dispatching without memorizing event names.
Example
const stateMachine = createDefaultRotateControlStateMachine(cameraRig);
// User rotates - accepted in ACCEPTING_USER_INPUT state
const result = stateMachine.notifyRotateByInput(Math.PI / 4);
// Start animation - transitions to TRANSITION state
stateMachine.notifyRotateToAnimationInput(Math.PI);
// User input now blocked while animatingSee
createDefaultRotateControlStateMachine for factory function
Extends
TemplateStateMachine<RotateEventPayloadMapping,BaseContext,RotateControlStates,RotateControlOutputMapping>
Constructors
Constructor
new RotateControlStateMachine(
states,initialState,context):RotateControlStateMachine
Defined in: packages/board/src/camera/camera-mux/animation-and-lock/rotation-control-state-machine.ts:134
Parameters
states
Record<RotateControlStates, State<RotateEventPayloadMapping, BaseContext, RotateControlStates, RotateControlOutputMapping>>
initialState
context
BaseContext
Returns
RotateControlStateMachine
Overrides
TemplateStateMachine< RotateEventPayloadMapping, BaseContext, RotateControlStates, RotateControlOutputMapping >.constructor
Properties
_context
protected_context:BaseContext
Defined in: packages/being/dist/interface.d.ts:383
Inherited from
TemplateStateMachine._context
_currentState
protected_currentState:RotateControlStates|"INITIAL"|"TERMINAL"
Defined in: packages/being/dist/interface.d.ts:381
Inherited from
TemplateStateMachine._currentState
_happensCallbacks
protected_happensCallbacks: (args,context) =>void[]
Defined in: packages/being/dist/interface.d.ts:386
Parameters
args
["userRotateByInput", RotateByInputEventPayload] | ["userRotateToInput", RotateToInputEventPayload] | ["transitionRotateByInput", RotateByInputEventPayload] | ["transitionRotateToInput", RotateToInputEventPayload] | ["lockedOnObjectRotateByInput", RotateByInputEventPayload] | ["lockedOnObjectRotateToInput", RotateToInputEventPayload] | ["unlock"] | ["initateTransition"] | [string, unknown]
context
BaseContext
Returns
void
Inherited from
TemplateStateMachine._happensCallbacks
_initialState
protected_initialState:RotateControlStates
Defined in: packages/being/dist/interface.d.ts:388
Inherited from
TemplateStateMachine._initialState
_stateChangeCallbacks
protected_stateChangeCallbacks:StateChangeCallback<RotateControlStates>[]
Defined in: packages/being/dist/interface.d.ts:385
Inherited from
TemplateStateMachine._stateChangeCallbacks
_states
protected_states:Record<States,State<EventPayloadMapping,Context,States,EventOutputMapping>>
Defined in: packages/being/dist/interface.d.ts:382
Inherited from
TemplateStateMachine._states
_statesArray
protected_statesArray:RotateControlStates[]
Defined in: packages/being/dist/interface.d.ts:384
Inherited from
TemplateStateMachine._statesArray
_timeouts
protected_timeouts:number|undefined
Defined in: packages/being/dist/interface.d.ts:387
Inherited from
KmtInputStateMachineWebWorkerProxy._timeouts
Accessors
currentState
Get Signature
get currentState():
States|"INITIAL"|"TERMINAL"
Defined in: packages/being/dist/interface.d.ts:398
Returns
States | "INITIAL" | "TERMINAL"
Inherited from
TemplateStateMachine.currentState
possibleStates
Get Signature
get possibleStates():
States[]
Defined in: packages/being/dist/interface.d.ts:400
Returns
States[]
Inherited from
TemplateStateMachine.possibleStates
states
Get Signature
get states():
Record<States,State<EventPayloadMapping,Context,States,EventOutputMapping>>
Defined in: packages/being/dist/interface.d.ts:401
Returns
Record<States, State<EventPayloadMapping, Context, States, EventOutputMapping>>
Inherited from
TemplateStateMachine.states
Methods
happens()
Call Signature
happens<
K>(...args):EventResult<RotateControlStates,Kextends keyofRotateControlOutputMapping?RotateControlOutputMapping[K<K>] :void>
Defined in: packages/being/dist/interface.d.ts:394
Type Parameters
K
K extends keyof RotateEventPayloadMapping
Parameters
args
...EventArgs<RotateEventPayloadMapping, K>
Returns
EventResult<RotateControlStates, K extends keyof RotateControlOutputMapping ? RotateControlOutputMapping[K<K>] : void>
Inherited from
TemplateStateMachine.happens
Call Signature
happens<
K>(...args):EventResult<RotateControlStates,unknown>
Defined in: packages/being/dist/interface.d.ts:395
Type Parameters
K
K extends string
Parameters
args
...EventArgs<RotateEventPayloadMapping, K>
Returns
EventResult<RotateControlStates, unknown>
Inherited from
TemplateStateMachine.happens
initateTransition()
initateTransition():
void
Defined in: packages/board/src/camera/camera-mux/animation-and-lock/rotation-control-state-machine.ts:185
Initiates transition to TRANSITION state.
Returns
void
Remarks
Forces state change to begin animation or transition sequence. Called when starting programmatic camera movements.
notifyRotateByInput()
notifyRotateByInput(
diff):EventResult<RotateControlStates,RotateControlOutputEvent>
Defined in: packages/board/src/camera/camera-mux/animation-and-lock/rotation-control-state-machine.ts:160
Notifies the state machine of user rotation input.
Parameters
diff
number
Rotation angle delta in radians
Returns
EventResult<RotateControlStates, RotateControlOutputEvent>
Event handling result with output event
Remarks
Dispatches userRotateByInput event. Accepted in ACCEPTING_USER_INPUT and TRANSITION states, where it may transition back to ACCEPTING_USER_INPUT (user interrupting animation).
notifyRotateToAnimationInput()
notifyRotateToAnimationInput(
target):EventResult<RotateControlStates,RotateControlOutputEvent>
Defined in: packages/board/src/camera/camera-mux/animation-and-lock/rotation-control-state-machine.ts:174
Initiates a rotation animation to a target angle.
Parameters
target
number
Target rotation angle in radians
Returns
EventResult<RotateControlStates, RotateControlOutputEvent>
Event handling result
Remarks
Dispatches transitionRotateToInput event, starting a rotation animation. Transitions to TRANSITION state where animation updates occur.
onHappens()
onHappens(
callback):void
Defined in: packages/being/dist/interface.d.ts:397
Parameters
callback
(args, context) => void
Returns
void
Inherited from
TemplateStateMachine.onHappens
onStateChange()
onStateChange(
callback):void
Defined in: packages/being/dist/interface.d.ts:396
Parameters
callback
StateChangeCallback<RotateControlStates>
Returns
void
Inherited from
TemplateStateMachine.onStateChange
reset()
reset():
void
Defined in: packages/being/dist/interface.d.ts:390
Returns
void
Inherited from
TemplateStateMachine.reset
setContext()
setContext(
context):void
Defined in: packages/being/dist/interface.d.ts:399
Parameters
context
BaseContext
Returns
void
Inherited from
TemplateStateMachine.setContext
start()
start():
void
Defined in: packages/being/dist/interface.d.ts:391
Returns
void
Inherited from
TemplateStateMachine.start
switchTo()
switchTo(
state):void
Defined in: packages/being/dist/interface.d.ts:393
Parameters
state
RotateControlStates | "INITIAL" | "TERMINAL"
Returns
void
Inherited from
TemplateStateMachine.switchTo
wrapup()
wrapup():
void
Defined in: packages/being/dist/interface.d.ts:392
Returns
void
Inherited from
TemplateStateMachine.wrapup