spatial-controls
Version:
Configurable 3D movement controls.
97 lines (96 loc) • 2.38 kB
TypeScript
import { Action } from "../core/Action.js";
/**
* Input bindings.
*
* @group Settings
* @param TKey - The type of the binding keys.
*/
export declare class Bindings<TKey> {
/**
* The default bindings.
*/
defaultActions: Map<TKey, Action>;
/**
* A collection that maps keys to actions.
*/
actions: Map<TKey, Action>;
/**
* Constructs new input bindings.
*/
constructor();
/**
* Resets the current bindings to match the default bindings.
*
* @return This instance.
*/
reset(): Bindings<TKey>;
/**
* Establishes default bindings and resets the current bindings.
*
* @param actions - A collection that maps keys to actions.
* @return This instance.
*/
setDefault(actions: Map<TKey, Action>): Bindings<TKey>;
/**
* Clears the default bindings.
*
* @return This instance.
*/
clearDefault(): Bindings<TKey>;
/**
* Clears the current bindings.
*
* @return This instance.
*/
clear(): Bindings<TKey>;
/**
* Copies the given bindings, including the default bindings.
*
* @param bindings - Bindings.
* @return This instance.
*/
copy(bindings: Bindings<TKey>): Bindings<TKey>;
/**
* Clones these bindings.
*
* @return The cloned bindings.
*/
clone(): Bindings<TKey>;
/**
* Copies the given JSON data.
*
* @param json - The JSON data.
* @return This instance.
*/
fromJSON(json: Bindings<TKey>): Bindings<TKey>;
/**
* Checks if the given key is bound to an action.
*
* @param key - A key.
* @return Whether the given key is bound to an action.
*/
has(key: TKey): boolean;
/**
* Returns the action that is bound to the given key.
*
* @param key - A key.
* @return The action, or undefined if the key is not bound to any action.
*/
get(key: TKey): Action | undefined;
/**
* Binds a key to an action.
*
* @param key - A key.
* @param action - An action.
* @return This instance.
*/
set(key: TKey, action: Action): Bindings<TKey>;
/**
* Unbinds a key.
*
* @param key - The key.
* @return Whether the binding existed.
*/
delete(key: TKey): boolean;
toJSON(): Record<string, unknown>;
}