Function globalToLocal

  • Translate the specified x and y values from the global (absolute) coordinate to local (viewport) relative coordinate.

    Parameters

    • x: number

      the global x coordinate to be translated.

    • y: number

      the global y coordinate to be translated.

    • Optionalv: Vector2d

      an optional vector object where to set the translated coordinates

    Returns Vector2d

    A vector object with the corresponding translated coordinates

    input

    onMouseEvent : function (pointer) {
    // convert the given into local (viewport) relative coordinates
    let pos = me.input.globalToLocal(pointer.clientX, pointer.clientY);
    // do something with pos !
    };