Skip to content

@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

BoardCamera

Current camera instance (provides rotationBoundaries)

config

RotationHandlerClampConfig

Clamping configuration

Returns

number

Clamped rotation angle

Remarks

This handler enforces angular limits on absolute rotation requests.

Behavior:

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