11var Vector2 = require ( '../../../math/Vector2' ) ;
22
3- var GetWorldPoint = function ( screenPoint , output )
3+ var GetWorldPoint = function ( x , y , output )
44{
5+ if ( output === undefined ) { output = new Vector2 ( ) ; }
6+
57 var cameraMatrix = this . matrix . matrix ;
8+
69 var mva = cameraMatrix [ 0 ] ;
710 var mvb = cameraMatrix [ 1 ] ;
811 var mvc = cameraMatrix [ 2 ] ;
@@ -15,7 +18,10 @@ var GetWorldPoint = function (screenPoint, output)
1518
1619 if ( ! determinant )
1720 {
18- return screenPoint ;
21+ output . x = x ;
22+ output . y = y ;
23+
24+ return output ;
1925 }
2026
2127 determinant = 1 / determinant ;
@@ -26,22 +32,21 @@ var GetWorldPoint = function (screenPoint, output)
2632 var imd = mva * determinant ;
2733 var ime = ( mvc * mvf - mvd * mve ) * determinant ;
2834 var imf = ( mvb * mve - mva * mvf ) * determinant ;
35+
2936 var c = Math . cos ( this . rotation ) ;
3037 var s = Math . sin ( this . rotation ) ;
38+
3139 var zoom = this . zoom ;
40+
3241 var scrollX = this . scrollX ;
3342 var scrollY = this . scrollY ;
34- var x = screenPoint . x + ( ( scrollX * c - scrollY * s ) * zoom ) ;
35- var y = screenPoint . y + ( ( scrollX * s + scrollY * c ) * zoom ) ;
3643
37- if ( ! output )
38- {
39- output = new Vector2 ( ) ;
40- }
44+ var sx = x + ( ( scrollX * c - scrollY * s ) * zoom ) ;
45+ var sy = y + ( ( scrollX * s + scrollY * c ) * zoom ) ;
4146
4247 /* Apply transform to point */
43- output . x = ( x * ima + y * imc + ime ) ;
44- output . y = ( x * imb + y * imd + imf ) ;
48+ output . x = ( sx * ima + sy * imc + ime ) ;
49+ output . y = ( sx * imb + sy * imd + imf ) ;
4550
4651 return output ;
4752} ;
0 commit comments