input.globalToLocal

globalToLocal(x: number, y: number, v: Vector2d) → {Vector2d}

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

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

the global x coordinate to be translated.

y number

the global y coordinate to be translated.

v Vector2d

<optional>

an optional vector object where to set the translated coordinates

Returns:
Type Description
Vector2d

A vector object with the corresponding translated coordinates

Powered by webdoc!