input
Descriptionβ
This library includes functions that handle input management.Functionsβ
disablePointerLockRequestβ
Disables the pointer lock request on click.
world.input.disablePointerLockRequest() // -> void
enablePointerLockRequestβ
Request a pointer lock from the user when the screen is clicked.
world.input.enablePointerLockRequest() // -> void
getActionβ
Returns > 0 if the action was triggered. Value is usually from 0 to 1. The exception is mouse velocity and scroll which is uncapped.
world.input.getAction(actionName: string) // -> number
getActiveMapβ
Get the active action map.
world.input.getActiveMap() // -> string (Name of the active action map)
setActiveMapβ
Sets the active action map. The default action map's name is 'default'.
world.input.setActiveMap(mapName: string) // -> void
getAxisβ
Returns the value of the axis of the gamepadIdx.
world.input.getAxis(gamepadIdx?: number) // -> number[]
getButtonβ
Returns true while the virtual button identified by buttonName is held down.
world.input.getAxis(input: number, gamepadIdx?: number) // -> boolean
getButtonDownβ
Returns true during the frame the user pressed down the button mapped to the index.
world.input.getAxis(input: number, gamepadIdx?: number) // -> boolean
getButtonUpβ
Returns true the first frame the user releases the button.
world.input.getAxis(input: number, gamepadIdx?: number) // -> boolean
getGamepadsβ
Returns all gamepads connected to the device.
world.input.getGamepads() // -> Gamepad[]
getKeyβ
Returns true while the user holds down the key identified by name.
world.input.getKey(code: string) // -> boolean
getKeyDownβ
Returns true during the frame the user starts pressing down the key identified by name.
world.input.getKeyDown(code: string) // -> boolean
getKeyUpβ
Returns true during the frame the user releases the key identified by name.
world.input.getKeyUp(code: string) // -> boolean
getMouseButtonβ
Returns true while the user holds down the mouse button identified by button number.
Number | Mouse Button |
---|---|
0 | Left Click |
1 | Right Click |
2 | Middle Click |
world.input.getMouseButton(index: number) // -> boolean
getMouseDownβ
Returns true during the frame the user starts pressing down on the mouse button.
world.input.getMouseDown(index: number) // -> boolean
getMouseUpβ
Returns true during the frame the user releases the mouse button.
world.input.getMouseUp(index: number) // -> boolean
getMousePositionβ
Returns the x and y position of the mouse in the screen.
world.input.getMousePosition() // -> [number, number]
getMouseVelocityβ
Returns the x and y velocity of the mouse.
world.input.getMouseVelocity() // -> [number, number]
getMouseScrollβ
Return the x and y velocity of mouse scroll.
world.input.getMouseScroll() // -> [number, number]