API

Class InputMapper<THandlers>

Generic input-to-interaction mapper that resolves physical input events to semantic interaction types and dispatches them to typed handlers.

InputMapper is not tied to cameras — any object that needs a configurable, prioritized mapping from physical inputs (pointer, keyboard, wheel, touch) to named interactions can use it.

The mapper holds an ordered inputMap array. When resolveInteraction is called, the first entry whose source and conditions match the current input wins. More specific entries (with more conditions like button, key, modifiers) should be placed before less specific ones; use addEntry to auto-insert based on specificity.

Type Parameters

  • THandlers extends Record<string, unknown>

    Object type whose keys are the valid interaction type strings and values are the handler functions/objects for each interaction (e.g. ArcRotateHandlers). Interaction types are derived as InteractionName<THandlers>.

Index
handlers: THandlers

Interaction handlers keyed by interaction type. Override individual handlers to customize behavior without changing input mapping.

Ordered list of input-to-interaction mapping rules. First matching entry wins.

  • Sets the interaction for the input combination described by conditions. If an existing entry maps that exact combination, its interaction is updated in place; otherwise a new entry is inserted via addEntry.

    To force an update on every matching entry use setInteractions; to address an individual entry beyond the first, look it up via getEntries and assign entry.interaction directly.

    Parameters

    Returns boolean

    true (the mapping is always made effective)

  • Changes the interaction for every inputMap entry matching the given source and conditions. Useful when more than one entry maps to the same physical input (e.g. duplicate bindings, or several keys aliased to the same action) and all of them should be remapped together.

    Parameters

    • source: InputSource

      The physical input source to match

    • conditions: InputConditions | undefined

      Conditions to match (button, modifiers, key, etc.). Uses the same event-resolution semantics as resolveInteraction: omitted entry condition fields are treated as wildcards and will match.

    • interaction: InteractionName<THandlers>

      The new interaction to assign to every matched entry

    Returns number

    The number of entries that were updated