Skip to content

@ue-too/board / index / convertDeltaInWorldToViewPortSpace

関数: convertDeltaInWorldToViewPortSpace() ​

convertDeltaInWorldToViewPortSpace(delta, cameraZoomLevel, cameraRotation): Point

定義: packages/board/src/camera/utils/coordinate-conversion.ts:413

Converts a displacement vector from world space to viewport space. Use this for converting movement deltas, not absolute positions. Inverse of convertDeltaInViewPortToWorldSpace.

パラメータ ​

delta ​

Point

Displacement vector in world coordinates

cameraZoomLevel ​

number

Camera zoom level

cameraRotation ​

number

Camera rotation in radians

戻り値 ​

Point

Displacement vector in viewport space (CSS pixels)

Remarks ​

This transforms a relative displacement, not an absolute point. The conversion accounts for:

  • Rotation: Delta is rotated by -camera rotation
  • Zoom: Delta is scaled by zoom (world units → viewport pixels)

例 ​

typescript
// Object moved 50 units right in world space
const worldDelta = { x: 50, y: 0 };
const viewportDelta = convertDeltaInWorldToViewPortSpace(
  worldDelta,
  2.0,  // 2x zoom
  0     // no rotation
);
// Result: { x: 100, y: 0 } (50 world units = 100 viewport pixels at 2x zoom)