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]