# orbitControl() only works after a double tap (mobile)

**URL:** <https://discourse.processing.org/t/orbitcontrol-only-works-after-a-double-tap-mobile/29661>\
**Category:** Coding Questions\
**Created:** [April 26, 2021, 5:57pm UTC](https://discourse.processing.org/t/orbitcontrol-only-works-after-a-double-tap-mobile/29661 "2021-04-26T17:57:00Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![andypurbrick](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@andypurbrick](https://discourse.processing.org/u/andypurbrick)\
**Post date:** [April 26, 2021, 5:57pm UTC](https://discourse.processing.org/t/orbitcontrol-only-works-after-a-double-tap-mobile/29661/1 "2021-04-26T17:57:01Z")

</div>

I have a sketch with a rotating cube that uses the orbitControl() to allow it to be moved on its X axis, however, orbit controls only work if I double tap the screen.

As far as I’m aware this is not expected behaviour for orbitControl() and it should work as soon as I first touch the screen. There are no errors in my console and everything with my sketch works fine.

My draw function is as follows:

```auto
p5.draw = function(){

  p5.background(0,0);
  p5.ambientLight(220);
  p5.angleMode(p5.DEGREES)
  p5.noStroke();
  p5.normalMaterial();
  p5.orbitControl(5, 0, 0);
  
  cube.drawCube();

};

```

Unfortunately, I’m unable to post the full code as it’s for a client at work but I was wondering if anyone else has encountered this issue?

Many thanks,

Andy

---

<div class="post-metadata">

**Author:** ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)\
**Post date:** [April 26, 2021, 6:28pm UTC](https://discourse.processing.org/t/orbitcontrol-only-works-after-a-double-tap-mobile/29661/2 "2021-04-26T18:28:44Z")

</div>

Hi! even if you cannot release the whole code, you can make a small sketch to demonstrate the issue:

[https://editor.p5js.org/micuat/sketches/sESdEBWfm](https://editor.p5js.org/micuat/sketches/sESdEBWfm)

but I’m confused that the orbit control doesn’t run completely in my example (on iOS, old SE). Nevertheless, the example on the reference page seems to work, but as you mentioned I need to tap it once

[https://p5js.org/reference/#/p5/orbitControl](https://p5js.org/reference/#/p5/orbitControl)

---

<div class="post-metadata">

**Author:** ![andypurbrick](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@andypurbrick](https://discourse.processing.org/u/andypurbrick)\
**Post date:** [April 27, 2021, 8:29am UTC](https://discourse.processing.org/t/orbitcontrol-only-works-after-a-double-tap-mobile/29661/3 "2021-04-27T08:29:01Z")

</div>

Hi, thanks for your reply - I will in future post an example sketch to illustrate the issue as you suggest.

In terms of the examples that you have shared, with your own sketch orbitControl doesn’t work at all on iPhone8 iOS14 Safari and will only initiate after a tap on Android 10 Chrome v90.

The p5.js reference sketch works on both the above devices but requires a tap to initiate orbitControl which I don’t believe is the expected behaviour.

---

<div class="post-metadata">

**Author:** ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)\
**Post date:** [April 27, 2021, 8:42am UTC](https://discourse.processing.org/t/orbitcontrol-only-works-after-a-double-tap-mobile/29661/4 "2021-04-27T08:42:15Z")

</div>

I can only say that webgl on p5.js is still under development and “not the expected behavior” is not surprising to me. Unless someone else here can help you, I suggest opening an issue on github which perhaps is a better way to move the discussion forward as I’m no familiar with the code base of webgl.

The other thing is that I usually don’t recommend to use p5.js for production use - not saying that p5.js is not _good_, but it’s not made for production and I see these issues occur once in a while (plus not to mention performance issues). For 3D, three.js and a-frame are always good options 🙂

---

<div class="post-metadata">

**Author:** ![andypurbrick](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@andypurbrick](https://discourse.processing.org/u/andypurbrick)\
**Post date:** [April 27, 2021, 8:56am UTC](https://discourse.processing.org/t/orbitcontrol-only-works-after-a-double-tap-mobile/29661/5 "2021-04-27T08:56:18Z")

</div>

Thanks for your feedback, it’s much appreciated. I’ll open an issue on Github as you’ve suggested.

It’s good to know that p5 is not necessarily recommended for production use. I have managed to achieve the desired effect using three.js so I’m not completely stuck and will migrate to that if I can’t find a solution for p5.

Thanks again for your help! 🙂

---

<div class="post-metadata">

**Author:** ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)\
**Post date:** [April 27, 2021, 9:19am UTC](https://discourse.processing.org/t/orbitcontrol-only-works-after-a-double-tap-mobile/29661/6 "2021-04-27T09:19:48Z")

</div>

just to clarify - production use is usually not “supported” by any open source projects. But what I mean is the population of the users - tools like openFrameworks or this case three.js are used by quite a lot of designers/programmers who use them for production, so these tools are more polished in terms of testing on different platforms, durability etc. However, p5.js is more oriented to education and sometimes these points are missed out.

---

<div class="post-metadata">

**Author:** ![andypurbrick](https://avatars.discourse-cdn.com/v4/letter/a/b2d939/32.png) [@andypurbrick](https://discourse.processing.org/u/andypurbrick)\
**Post date:** [April 28, 2021, 11:12am UTC](https://discourse.processing.org/t/orbitcontrol-only-works-after-a-double-tap-mobile/29661/7 "2021-04-28T11:12:21Z")

</div>

Someone has already opened an issue for this on this on Github and they have [posted a temporary solution](https://github.com/processing/p5.js/issues/5176) that resolves the issue on mobile.

Hopefully, a long term fix will come in the next version.
