@ue-too/board / clampRotateToHandler
Function: clampRotateToHandler()
clampRotateToHandler(
targetRotation,camera,config):number
Defined in: packages/board/src/camera/camera-rig/rotation-handler.ts:336
Handler pipeline step that clamps "rotate to" targets to camera rotation boundaries.
Parameters
targetRotation
number
Target rotation angle in radians
camera
Current camera instance (provides rotationBoundaries)
config
Clamping configuration
Returns
number
Clamped rotation angle
Remarks
This handler enforces angular limits on absolute rotation requests.
Behavior:
- If
clampRotationis false: Returns target unchanged - If
clampRotationis true: Clamps target to BoardCamera.rotationBoundaries
The clamping handles:
- Missing boundaries (undefined min/max)
- One-sided constraints (only min or only max)
- Full range constraints
Example
typescript
camera.rotationBoundaries = { min: 0, max: Math.PI }; // [0°, 180°]
const config: RotationHandlerClampConfig = {
clampRotation: true
};
const target = Math.PI * 1.5; // 270 degrees (exceeds max)
const clamped = clampRotateToHandler(target, camera, config);
// clamped = π (180 degrees - clamped to max boundary)See
- clampRotation for clamping implementation
- createDefaultRotateToHandler for default pipeline usage