MouseInput
The MouseInput class is designed to help you handle mouse input in your applications.
start()
Starts capturing mouse input.
Example:
Input.mouse.start();
stop()
Stops capturing mouse input by removing all event listeners.
Example:
Input.mouse.stop();
isButtonPressed(button: MouseButton): boolean
Checks if a specific mouse button is currently pressed.
Example:
if (Input.mouse.isButtonPressed(MouseButton.Left)) {
console.log('Left mouse button pressed');
}
isButtonReleased(button: MouseButton): boolean
Checks if a specific mouse button has been released.
Example:
if (Input.mouse.isButtonReleased(MouseButton.Right)) {
console.log('Right mouse button released');
}
position(): THREE.Vector2
Gets the current mouse position in screen space.
Example:
const pos = Input.mouse.position();
console.log(pos.x, pos.y);
wheelDelta(): number
Gets the change in scroll values (delta) since the last scroll event.
Example:
const delta = Input.mouse.wheelDelta();
console.log(delta);
raycast(camera: THREE.Camera): RaycastOutput
Computes the mouse position and calculates the raycaster and cursor position.
Example:
const rayOutput = Input.mouse.raycast(camera);
console.log(rayOutput.raycaster, rayOutput.position);