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

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.


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.

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

a bit hacky but I made it

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 :wink:

I guess wrapping around with push/pop will solve it

1 Like