Skip to content

@ue-too/board / createDefaultRotateByHandler

Function: createDefaultRotateByHandler()

createDefaultRotateByHandler(): RotateByHandlerFunction

Defined in: packages/board/src/camera/camera-rig/rotation-handler.ts:429

Creates a default "rotate by" handler pipeline for relative rotation operations.

Returns

RotateByHandlerFunction

Rotate-by handler function with restriction and clamping

Remarks

The default handler pipeline applies transformations in this order:

  1. Restriction (restrictRotateByHandler): Returns zero delta if locked
  2. Clamping (clampRotateByHandler): Adjusts delta to respect boundaries

This ensures that:

  • Rotation can be completely disabled via restrictRotation flag
  • Resulting rotation angle stays within configured angular boundaries
  • Delta is adjusted to prevent boundary violations

Example

typescript
const rotateBy = createDefaultRotateByHandler();

camera.rotation = Math.PI * 0.4;  // 72 degrees
camera.rotationBoundaries = { max: Math.PI / 2 };  // Max 90 degrees

const delta = Math.PI * 0.3;  // Try to rotate 54 degrees (would exceed max)
const constrained = rotateBy(delta, camera, {
  clampRotation: true,
  restrictRotation: false
});
// constrained adjusted to only rotate to boundary
camera.setRotation(camera.rotation + constrained);

See