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

備註

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)

參閱