dot big bang

Developer API
Menu

Class Mouse

All
  • Public
  • Public/Protected
  • All

Hierarchy

  • Mouse

Index

Accessors

buttonsPressed

  • get buttonsPressed(): number
  • Gets all the buttons currently being held pressed as MouseButton bit field number.

    Returns number

isPointerLocked

  • get isPointerLocked(): boolean
  • Indicates whether "pointer lock" mode is currently active on the Game canvas. When pointer lock is active, the absolute position of the mouse, as returned by getPosition(), stays locked onto the same value. The mouse movements are reported with getPointerLockMovement() as increments/deltas relative to the previous frame. And the mouse cursor isn't visible on screen anymore.

    Returns boolean

Methods

exitPointerLock

  • exitPointerLock(): void
  • Requests the browser to exit "pointer lock" mode on the Game canvas. When pointer lock is active, the absolute position of the mouse, as returned by getPosition(), stays locked onto the same value. The mouse movements are reported with getPointerLockMovement() as increments/deltas relative to the previous frame. And the mouse cursor isn't visible on screen anymore. Exiting pointer lock isn't immediate. It might take a couple of frames for isPointerLocked() to return false.

    Returns void

getHeldTime

  • Returns how long the button has been held (0 if it's not held) in seconds.

    Parameters

    Returns number

getPointerLockMovement

  • Returns how much the mouse pointer moved, in CSS Pixel(???), since last frame, when in "pointer lock" mode. Returns the zero vector when not in "pointer lock" mode. When pointer lock is active, the absolute position of the mouse, as returned by getPosition(), stays locked onto the same value. The mouse movements are reported with getPointerLockMovement() as increments/deltas relative to the previous frame. And the mouse cursor isn't visible on screen anymore.

    Parameters

    Returns Vector2

getPosition

  • Gets the position, in CSS pixels, of the mouse pointer relative to the top-left corner of the 3D canvas used to render the Game.

    Parameters

    • Optional optionalTarget: Vector2

      When not provided, the method creates an object to store the result and then returns it. Providing this argument avoids this object allocation.

    Returns Vector2

getWheelDelta

  • Gets how much the mouse wheel moved since last frame. The value are approximately measured in CSS pixels scrolled on screen (in a standard text-based webpage). The result is a Vector2. The x component is the delta value for the primary wheel which, on a typical mouse, is usually a physical wheel. Interacting with it on a standard text-based webpage scrolls the page vertically. The y component is the delta value for the secondary axis of the wheel, which scrolls a text-based webpage horizontally. Not all mice with wheel have such secondary axis. However, in most browsers, the secondary axis can be emulated by holding Shift and using the primary vertical axis. Lastly, laptop touchpads (or mice with touch surface, like the Apple Magic Mouse) also report wheel deltas whenever scrolling gestures occur. Zoom gestures, typically pinching with two fingers, are also reported as wheel deltas but the browser in this case indicates it by simulating/reporting the Control key as being pressed.

    Parameters

    • Optional optionalTarget: Vector2

      When not provided, the method creates an object to store the result and then returns it. Providing this argument avoids this object allocation.

    Returns Vector2

isButtonJustPressed

  • Indicates whether the given button was just pressed this frame.

    Parameters

    Returns boolean

isButtonJustReleased

  • Indicates whether the given button was just released this frame.

    Parameters

    Returns boolean

isButtonPressed

  • Indicates whether the given mouse button is pressed. (either just pressed this frame, or being held from previous frames)

    Parameters

    Returns boolean

requestPointerLock

  • requestPointerLock(): void
  • Requests the browser to enter "pointer lock" mode on the Game canvas. When pointer lock is active, the absolute position of the mouse, as returned by getPosition(), stays locked onto the same value. The mouse movements are reported with getPointerLockMovement() as increments/deltas relative to the previous frame. And the mouse cursor isn't visible on screen anymore. Entering pointer lock isn't immediate. It might take a couple of frames for isPointerLocked() to return true.

    Returns void