Skip to content

@ue-too/board / index / restrictPanToHandler

函式: restrictPanToHandler()

restrictPanToHandler(destination, camera, config): Point

定義於: packages/board/src/camera/camera-rig/pan-handler.ts:359

Handler pipeline step that applies axis restrictions to "pan to" destinations.

參數

destination

Point

Target camera position in world space

camera

BoardCamera

Current camera instance

config

PanHandlerRestrictionConfig

Restriction configuration

回傳

Point

Restricted destination position

備註

This handler enforces axis-lock constraints on absolute camera positioning. It converts the destination to a delta, applies restrictions, then converts back.

Algorithm:

  1. Calculate delta from current position to destination
  2. Apply restrictions using convertDeltaToComplyWithRestriction
  3. If delta becomes zero, return original destination (already at target)
  4. Otherwise, return current position + restricted delta

Can be used standalone, but typically composed into a handler pipeline via createDefaultPanToHandler or createHandlerChain.

範例

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 }

參閱