mouse_transform()
Get mouse coordinates relative to the canvas and to the browser client.
Parameters:
event: DOMEvent
: The DOM Event object for mouse movement. Used to calculate to position of the pointer insicde the canvas.
mouse_position:{x:number, y: number, raw:{x: number, y:number}
: The mouse position object to update, we update all the properties by reference on this object to avoid unbinding events, watchers, or listeners to this object.
canvas_element: DOMEelement
: The DOM Element that contains the canvas to calculate the position.
Description:
Calculates the mouse position in world space and relative to the browser client.
Returns:
A new mouse_position
object: {x: number, y:number, raw: {x: number, y: number}
.
The raw
object give the coordinates relative the the browser client, while the top-level x
why y
are the position in world space inside the canvas.
Updated about 3 years ago