Skip to content

Commit e9d7940

Browse files
committed
HitTest only tests the camera below the pointer and there is no benefit polling every single camera
1 parent 8980616 commit e9d7940

1 file changed

Lines changed: 10 additions & 11 deletions

File tree

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,19 @@
11
var HitTestPointer = function (pointer)
22
{
3-
var output = [];
3+
var camera = this.cameras.getCameraBelowPointer(pointer);
44

5-
// Get a list of all objects that can be seen by all the cameras in the scene and store in 'output' array.
6-
// All objects in this array are input enabled, as checked by the hitTest function, so we don't need to check later on as well.
7-
for (var i = 0; i < this.cameras.length; i++)
5+
if (camera)
86
{
9-
var camera = this.cameras[i];
7+
pointer.camera = camera;
108

11-
if (camera.inputEnabled)
12-
{
13-
output = output.concat(this.manager.hitTest(this._list, pointer.x, pointer.y, camera));
14-
}
9+
// Get a list of all objects that can be seen by the camera below the pointer in the scene and store in 'output' array.
10+
// All objects in this array are input enabled, as checked by the hitTest function, so we don't need to check later on as well.
11+
return this.manager.hitTest(this._list, pointer.x, pointer.y, camera);
12+
}
13+
else
14+
{
15+
return [];
1516
}
16-
17-
return output;
1817
};
1918

2019
module.exports = HitTestPointer;

0 commit comments

Comments
 (0)