Clamp device orientation controls

camera-controls
device-orientation

#1

I’m struggling to figure out how to clamp the device orientation controls to say 180 degrees rather than allowing the full 360.

Does anyone know how to do this?


#2

There’s no built in way to do this - however looking at the source code, the controls are pretty simple.

You’ll need to change the “update” function and add checks for
scope.deviceOrientation.alpha, scope.deviceOrientation.beta and scope.deviceOrientation.gamma - only update them if they are within your desired range.