Skip to content

Commit bd6dd41

Browse files
committed
transform point to camera space
1 parent 9b7b075 commit bd6dd41

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

v3/src/camera/Camera.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,29 @@ var Camera = new Class({
263263
return this;
264264
},
265265

266+
transformPoint: function (pointIn, pointOut)
267+
{
268+
var cameraMatrix = this.matrix.matrix;
269+
var mva = cameraMatrix[0];
270+
var mvb = cameraMatrix[1];
271+
var mvc = cameraMatrix[2];
272+
var mvd = cameraMatrix[3];
273+
var mve = cameraMatrix[4];
274+
var mvf = cameraMatrix[5];
275+
var x = pointIn.x;
276+
var y = pointIn.y;
277+
278+
if (!pointOut)
279+
{
280+
pointOut = {x: 0, y: 0};
281+
}
282+
283+
pointOut.x = (x * mva + y * mvc + mve) - scrollX;
284+
pointOut.y = (x * mvb + y * mvd + mvf) - scrollY;
285+
286+
return pointOut;
287+
},
288+
266289
preRender: function ()
267290
{
268291
var width = this.width;

0 commit comments

Comments
 (0)