@ue-too/board / createDefaultRotateToHandler
Function: createDefaultRotateToHandler()
createDefaultRotateToHandler():
RotateToHandlerFunction
Defined in: packages/board/src/camera/camera-rig/rotation-handler.ts:486
Creates a default "rotate to" handler pipeline for absolute rotation operations.
Returns
Rotate-to handler function with restriction and clamping
Remarks
The default handler pipeline applies transformations in this order:
- Restriction (restrictRotateToHandler): Returns current angle if locked
- Clamping (clampRotateToHandler): Clamps angle to configured boundaries
This ensures that:
- Rotation can be completely disabled via
restrictRotationflag - Rotation angle stays within configured angular boundaries
Examples
typescript
const rotateTo = createDefaultRotateToHandler();
camera.rotationBoundaries = { min: 0, max: Math.PI }; // [0°, 180°]
const target = Math.PI * 1.5; // 270 degrees (exceeds max)
const constrained = rotateTo(target, camera, {
clampRotation: true,
restrictRotation: false
});
// constrained = π (clamped to max boundary of 180 degrees)
camera.setRotation(constrained);typescript
// Create custom pipeline with snapping
const cardinalRotateTo = createHandlerChain<number, [BoardCamera, RotationHandlerConfig]>(
restrictRotateToHandler,
(angle) => {
// Snap to cardinal directions (0°, 90°, 180°, 270°)
const cardinals = [0, Math.PI/2, Math.PI, 3*Math.PI/2];
return cardinals.reduce((prev, curr) =>
Math.abs(curr - angle) < Math.abs(prev - angle) ? curr : prev
);
},
clampRotateToHandler
);See
- createHandlerChain for creating custom handler pipelines
- restrictRotateToHandler for the restriction step
- clampRotateToHandler for the clamping step