Skip to content

@ue-too/board / index / clampRotateToHandler

関数: clampRotateToHandler()

clampRotateToHandler(targetRotation, camera, config): number

定義: packages/board/src/camera/camera-rig/rotation-handler.ts:336

Handler pipeline step that clamps "rotate to" targets to camera rotation boundaries.

パラメータ

targetRotation

number

Target rotation angle in radians

camera

BoardCamera

Current camera instance (provides rotationBoundaries)

config

RotationHandlerClampConfig

Clamping configuration

戻り値

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

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)

参照