# What does babylon do when mouse is moved around the scene?

**URL:** <https://forum.babylonjs.com/t/what-does-babylon-do-when-mouse-is-moved-around-the-scene/9995>\
**Category:** Questions\
**Created:** [April 14, 2020, 4:59pm UTC](https://forum.babylonjs.com/t/what-does-babylon-do-when-mouse-is-moved-around-the-scene/9995 "2020-04-14T16:59:34Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Foxhoundn](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/foxhoundn/32/15613_2.png) [@Foxhoundn](https://forum.babylonjs.com/u/Foxhoundn)\
**Post date:** [April 14, 2020, 4:59pm UTC](https://forum.babylonjs.com/t/what-does-babylon-do-when-mouse-is-moved-around-the-scene/9995/1 "2020-04-14T16:59:35Z")

</div>

Today I noticed (on my Mac) that when I am moving the mouse around, the FPS drop to around ~5 while the scene is calm and nothing is happening.

Is there something Babylon is doing on every mouse move, like trying to pick for meshes? I disabled all of my mouseMoves, and I am not doing any picking except for rays. It happens also when the pointer is locked.

I didn’t notice it on my game PC because the drop isn’t really there but I sometimes see a few fps drops when rotating around, but on my Mac as you can see, the drops are massive.

[https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/8/8b9384481152f16ba570ed664eae59c2c9ad330d.mp4](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/8/8b9384481152f16ba570ed664eae59c2c9ad330d.mp4)

Even the video itself is lagging, maybe I can get a video on my phone and upload it to see it better.

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [April 14, 2020, 5:10pm UTC](https://forum.babylonjs.com/t/what-does-babylon-do-when-mouse-is-moved-around-the-scene/9995/2 "2020-04-14T17:10:57Z")

</div>

Yep, bjs will cast rays to all meshes with ActionManagers for instance

---

<div class="post-metadata">

**Author:** ![Foxhoundn](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/foxhoundn/32/15613_2.png) [@Foxhoundn](https://forum.babylonjs.com/u/Foxhoundn)\
**Post date:** [April 14, 2020, 5:14pm UTC](https://forum.babylonjs.com/t/what-does-babylon-do-when-mouse-is-moved-around-the-scene/9995/3 "2020-04-14T17:14:50Z")

</div>

I am not using ActionManager, is there anything else?

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [April 14, 2020, 5:32pm UTC](https://forum.babylonjs.com/t/what-does-babylon-do-when-mouse-is-moved-around-the-scene/9995/4 "2020-04-14T17:32:54Z")

</div>

any object with isPickable turned on?

can you share a repro maybe?

---

<div class="post-metadata">

**Author:** ![Foxhoundn](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/foxhoundn/32/15613_2.png) [@Foxhoundn](https://forum.babylonjs.com/u/Foxhoundn)\
**Post date:** [April 14, 2020, 6:06pm UTC](https://forum.babylonjs.com/t/what-does-babylon-do-when-mouse-is-moved-around-the-scene/9995/5 "2020-04-14T18:06:59Z")

</div>

Each of my rooms is a merged mesh of around 200-300 meshes, the merged mesh has `isPickable` set, but also all of it’s submeshes have it se to true (i suppose because of bounding boxes).

---

<div class="post-metadata">

**Author:** ![Foxhoundn](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/foxhoundn/32/15613_2.png) [@Foxhoundn](https://forum.babylonjs.com/u/Foxhoundn)\
**Post date:** [April 14, 2020, 6:09pm UTC](https://forum.babylonjs.com/t/what-does-babylon-do-when-mouse-is-moved-around-the-scene/9995/6 "2020-04-14T18:09:39Z")

</div>

Is there a way to ignore the picking on mouse movement? I’ve read a thread on it some time ago but forgot what was needed to be done.

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [April 14, 2020, 6:22pm UTC](https://forum.babylonjs.com/t/what-does-babylon-do-when-mouse-is-moved-around-the-scene/9995/7 "2020-04-14T18:22:46Z")

</div>

Yes, you can define your own picking predicates here:

[https://doc.babylonjs.com/api/classes/babylon.scene#pointermovepredicate](https://doc.babylonjs.com/api/classes/babylon.scene#pointermovepredicate)

example: [https://www.babylonjs-playground.com/#6LDNAE#6](https://www.babylonjs-playground.com/#6LDNAE#6) (line #26)

---

<div class="post-metadata">

**Author:** ![Foxhoundn](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/foxhoundn/32/15613_2.png) [@Foxhoundn](https://forum.babylonjs.com/u/Foxhoundn)\
**Post date:** [April 14, 2020, 6:37pm UTC](https://forum.babylonjs.com/t/what-does-babylon-do-when-mouse-is-moved-around-the-scene/9995/8 "2020-04-14T18:37:30Z")

</div>

Added

```auto
this.scene.pointerMovePredicate = () => false;
this.scene.pointerDownPredicate = () => false;
this.scene.pointerUpPredicate = () => false;

```

But nothing has changed.

All of the meshes have to be run through this function that just returns false anyway, so maybe I could PR a change that could disable these pointer checks?

I am not sure if this would fix my issue tho.

---

<div class="post-metadata">

**Author:** ![Foxhoundn](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/foxhoundn/32/15613_2.png) [@Foxhoundn](https://forum.babylonjs.com/u/Foxhoundn)\
**Post date:** [April 14, 2020, 6:40pm UTC](https://forum.babylonjs.com/t/what-does-babylon-do-when-mouse-is-moved-around-the-scene/9995/9 "2020-04-14T18:40:41Z")

</div>

So it’s not just my game - I updated your demo - [https://www.babylonjs-playground.com/#6LDNAE#6](https://www.babylonjs-playground.com/#6LDNAE#6)

If you move your mouse really quickly the fps drops to 6.

I set the `pointerMovePredicate = function (mesh) { return false }`

Btw this is on 2015 macbook pro retina, so you might not see the fps drops, but I see 60 to 6 really quickly.

Update: setting `pointerMovePredicate = null` did not help either

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [April 14, 2020, 8:01pm UTC](https://forum.babylonjs.com/t/what-does-babylon-do-when-mouse-is-moved-around-the-scene/9995/10 "2020-04-14T20:01:25Z")

</div>

This is because we were manually doing a pick

here is the version with no pointer pick on move: [https://www.babylonjs-playground.com/#6LDNAE#7](https://www.babylonjs-playground.com/#6LDNAE#7)

---

<div class="post-metadata">

**Author:** ![Foxhoundn](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/foxhoundn/32/15613_2.png) [@Foxhoundn](https://forum.babylonjs.com/u/Foxhoundn)\
**Post date:** [April 14, 2020, 8:03pm UTC](https://forum.babylonjs.com/t/what-does-babylon-do-when-mouse-is-moved-around-the-scene/9995/11 "2020-04-14T20:03:16Z")

</div>

Still the same, no change 60 to 10 fps in a few mouse moves. I gotta shower, will upload a vid in a min.

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [April 14, 2020, 9:24pm UTC](https://forum.babylonjs.com/t/what-does-babylon-do-when-mouse-is-moved-around-the-scene/9995/12 "2020-04-14T21:24:19Z")

</div>

this is the profile I just did:

 ![image](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/4/435ccc8c17a2c5abdd27fa5866b5e8e21791751f.png)

You can see that the pointermove is insignificant

---

<div class="post-metadata">

**Author:** ![Foxhoundn](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/foxhoundn/32/15613_2.png) [@Foxhoundn](https://forum.babylonjs.com/u/Foxhoundn)\
**Post date:** [April 14, 2020, 9:26pm UTC](https://forum.babylonjs.com/t/what-does-babylon-do-when-mouse-is-moved-around-the-scene/9995/13 "2020-04-14T21:26:53Z")

</div>

Ok, let me do a profile on the mac.

---

<div class="post-metadata">

**Author:** ![Foxhoundn](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/foxhoundn/32/15613_2.png) [@Foxhoundn](https://forum.babylonjs.com/u/Foxhoundn)\
**Post date:** [April 14, 2020, 9:32pm UTC](https://forum.babylonjs.com/t/what-does-babylon-do-when-mouse-is-moved-around-the-scene/9995/14 "2020-04-14T21:32:54Z")

</div>

Holy shit 🙂 I just figured it out.

I changed the polling of my Logitech g604 connected through LIGHTSPEED from 1000 to 125 and the issue is gone…

A wireless mouse totally knocks off WebGL because of the high polling rate.

Although using the trackpad also takes off good 10-20 fps so I think there is maybe still something going on.

---

<div class="post-metadata">

**Author:** ![Foxhoundn](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/foxhoundn/32/15613_2.png) [@Foxhoundn](https://forum.babylonjs.com/u/Foxhoundn)\
**Post date:** [April 14, 2020, 9:38pm UTC](https://forum.babylonjs.com/t/what-does-babylon-do-when-mouse-is-moved-around-the-scene/9995/15 "2020-04-14T21:38:45Z")

</div>

A 17 fps frame using the trackpad, lots of idle time.

 ![Screenshot 2020-04-14 at 23.37.41](https://us1.discourse-cdn.com/flex024/uploads/babylonjs/original/2X/a/a60565b4325e74cf82261f659a6f80272e7d19bb.png)

---

<div class="post-metadata">

**Author:** ![Deltakosh](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/deltakosh/32/26635_2.png) [@Deltakosh](https://forum.babylonjs.com/u/Deltakosh)\
**Post date:** [April 14, 2020, 10:19pm UTC](https://forum.babylonjs.com/t/what-does-babylon-do-when-mouse-is-moved-around-the-scene/9995/16 "2020-04-14T22:19:09Z")

</div>

definitely a system or driver issue

We can see that the JS code is remarkably quiet 😃

---

<div class="post-metadata">

**Author:** ![Foxhoundn](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/foxhoundn/32/15613_2.png) [@Foxhoundn](https://forum.babylonjs.com/u/Foxhoundn)\
**Post date:** [April 15, 2020, 9:01am UTC](https://forum.babylonjs.com/t/what-does-babylon-do-when-mouse-is-moved-around-the-scene/9995/17 "2020-04-15T09:01:17Z")

</div>

Yeah I suppose it’s a mac or chrome for mac system/driver issue.

I’ve read somewhere that the chrome for mac has WebGL issues.

---

<div class="post-metadata">

**Author:** ![horacio](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/horacio/32/9771_2.png) [@horacio](https://forum.babylonjs.com/u/horacio)\
**Post date:** [July 24, 2020, 6:05pm UTC](https://forum.babylonjs.com/t/what-does-babylon-do-when-mouse-is-moved-around-the-scene/9995/18 "2020-07-24T18:05:24Z")

</div>

I was Googling around to try to figure out why my game totally freezes when the mouse moves, even when I remove everything linked to capture mouse movement from the code.  
Your post made me realize it’s the same for me, no problem with my trackpad and only with my gaming mouse (G502, wired). I dropped the report rate from 1000 to 125 and it’s all good.  
Thanks!

---

<div class="post-metadata">

**Author:** ![gabrieljbaker](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/gabrieljbaker/32/12670_2.png) [@gabrieljbaker](https://forum.babylonjs.com/u/gabrieljbaker)\
**Post date:** [March 2, 2021, 7:32am UTC](https://forum.babylonjs.com/t/what-does-babylon-do-when-mouse-is-moved-around-the-scene/9995/19 "2021-03-02T07:32:53Z")

</div>

This is a really interesting thread. I’ve noticed this with my mouse as I move it moderately quickly over a series of 2d gui buttons with hover events or over the virtual keyboard. I will adjust the mouse settings tomorrow to see if that fixes it.

I wonder though, @RaananW , if this is responsible for the fps drops I get when moving my vr controller raycaster over the menu at a decent speed!

---

<div class="post-metadata">

**Author:** ![RaananW](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/raananw/32/28955_2.png) [@RaananW](https://forum.babylonjs.com/u/RaananW)\
**Post date:** [March 2, 2021, 12:03pm UTC](https://forum.babylonjs.com/t/what-does-babylon-do-when-mouse-is-moved-around-the-scene/9995/20 "2021-03-02T12:03:08Z")

</div>

@gabrieljbaker - WebXR works a bit different. In WebXR we are the ones polling the information ( on each frame). If your browser triggers the pointermove event 100 times every second, the pointer events will be triggered 100 times in babylon as well. As WebXR only emulates pointer events, it happens on each XR frame.

Writing this made me realize that one way to improve the performance here would be to not poll on each frame and allow the developer to define some form of a factor. The meshUnderPointer variable might change a frame or 2 after (well, depending on the factor, actually), but we will poll much less.

I am still looking into the virtual keyboard issue.
