# Is there a way to set orbitControl() to only affect a specific mesh?

**URL:** <https://discourse.processing.org/t/is-there-a-way-to-set-orbitcontrol-to-only-affect-a-specific-mesh/44549>\
**Category:** Coding Questions\
**Created:** [June 7, 2024, 8:42pm UTC](https://discourse.processing.org/t/is-there-a-way-to-set-orbitcontrol-to-only-affect-a-specific-mesh/44549 "2024-06-07T20:42:16Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jshaw3](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jshaw3/32/8336_2.png) [@jshaw3](https://discourse.processing.org/u/jshaw3)\
**Post date:** [June 7, 2024, 8:42pm UTC](https://discourse.processing.org/t/is-there-a-way-to-set-orbitcontrol-to-only-affect-a-specific-mesh/44549/1 "2024-06-07T20:42:16Z")

</div>

Is there a way to set orbitControl() to only affect a specific mesh? It doesn’t seem to be possible or a feature, but I wanted to throw the question out there in case there’s a way to implement it, and I just missed the docs.

I know it’s possible in PeasyCam for Java Processing (`camera.beginHUD();` etc), but I am wondering if in p5.js WEBGL, it’s possible to set orbitControl() and have the mouse controls only affect a specific mesh. Or like “lock” all webGL elements except a specific 3d shape.

The parameters for `orbitControl()` seem pretty limited, but I thought it was worth asking.

Thanks!

---

<div class="post-metadata">

**Author:** ![scudly](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/scudly/32/5597_2.png) [@scudly](https://discourse.processing.org/u/scudly)\
**Post date:** [June 7, 2024, 10:51pm UTC](https://discourse.processing.org/t/is-there-a-way-to-set-orbitcontrol-to-only-affect-a-specific-mesh/44549/2 "2024-06-07T22:51:34Z")

</div>

I haven’t tried it, but try making two camera objects. Set one camera and render part of the scene. Then set the other camera, initialized to the same place as the first, call `orbitControl()`, and render the object you want to have move.

I think `orbitControl()` should only move around the currently active camera. But, again, I haven’t tried it so it might not work.

---

<div class="post-metadata">

**Author:** ![jshaw3](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jshaw3/32/8336_2.png) [@jshaw3](https://discourse.processing.org/u/jshaw3)\
**Post date:** [June 7, 2024, 11:18pm UTC](https://discourse.processing.org/t/is-there-a-way-to-set-orbitcontrol-to-only-affect-a-specific-mesh/44549/3 "2024-06-07T23:18:16Z")

</div>

Ah, good call, and clever possible solution. I’ll give it a try and post back on it’s result!

---

<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:** [June 8, 2024, 10:49am UTC](https://discourse.processing.org/t/is-there-a-way-to-set-orbitcontrol-to-only-affect-a-specific-mesh/44549/4 "2024-06-08T10:49:13Z")

</div>

a bit hacky but I made it

> **[p5.js Web Editor](https://editor.p5js.org/micuat/sketches/jIXR2MI36)**
>
> A web editor for p5.js, a JavaScript library with the goal of making coding accessible to artists, designers, educators, and beginners.

basically taking the cameraMatrix (which contains translation and rotation modified by orbitControl), invert it and apply to cancel it out. Note that you need to shift Z direction according to the camera parameter.

edit: I noted in the sketch but transform will break it - I leave it as a homework for you 😉

---

<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:** [June 9, 2024, 12:50pm UTC](https://discourse.processing.org/t/is-there-a-way-to-set-orbitcontrol-to-only-affect-a-specific-mesh/44549/5 "2024-06-09T12:50:48Z")

</div>

I guess wrapping around with push/pop will solve it

> **[p5.js Web Editor](https://editor.p5js.org/micuat/sketches/e0oQKkCHf)**
>
> A web editor for p5.js, a JavaScript library with the goal of making coding accessible to artists, designers, educators, and beginners.
