@ue-too/board / restrictPanToHandler
Function: restrictPanToHandler()
restrictPanToHandler(
destination,camera,config):Point
Defined in: packages/board/src/camera/camera-rig/pan-handler.ts:359
Handler pipeline step that applies axis restrictions to "pan to" destinations.
Parameters
destination
Point
Target camera position in world space
camera
Current camera instance
config
Restriction configuration
Returns
Point
Restricted destination position
Remarks
This handler enforces axis-lock constraints on absolute camera positioning. It converts the destination to a delta, applies restrictions, then converts back.
Algorithm:
- Calculate delta from current position to destination
- Apply restrictions using convertDeltaToComplyWithRestriction
- If delta becomes zero, return original destination (already at target)
- Otherwise, return current position + restricted delta
Can be used standalone, but typically composed into a handler pipeline via createDefaultPanToHandler or createHandlerChain.
Example
typescript
// Standalone usage
const config: PanHandlerRestrictionConfig = {
restrictYTranslation: true, // Lock Y axis
restrictXTranslation: false,
restrictRelativeXTranslation: false,
restrictRelativeYTranslation: false
};
const destination = { x: 1000, y: 500 };
const restricted = restrictPanToHandler(destination, camera, config);
// If camera is at { x: 0, y: 200 }, result is { x: 1000, y: 200 }See
- convertDeltaToComplyWithRestriction for restriction logic
- createDefaultPanToHandler for default pipeline usage