All files / src/composables useScanMovement.ts

100% Statements 9/9
100% Branches 0/0
100% Functions 6/6
100% Lines 9/9

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32                    3x   119x   119x   119x   119x       59x 59x     236x 16x        
import { ScanMovementActions } from '@3cr/types-ts';
import { watch, WatchSource } from 'vue';
import { scanState } from '@/models/scanState';
import { useViewer3cr } from '@/composables/useViewer3cr';
 
type WatchScanMovement = {
  [key in ScanMovementActions]: WatchSource<number>;
};
 
// @ts-ignore
const movements: WatchScanMovement = {
  [ScanMovementActions.sm05]: () =>
    scanState.value.InteractionSettings.PanSensivitity,
  [ScanMovementActions.sm08]: () =>
    scanState.value.InteractionSettings.ZoomSensitivity,
  [ScanMovementActions.sm10]: () =>
    scanState.value.InteractionSettings.RotateSensitivity,
  [ScanMovementActions.sm12]: () =>
    scanState.value.InteractionSettings.CameraRotateSensitivity,
};
 
export function useScanMovement(): void {
  const viewer3cr = useViewer3cr();
  for (const movement of Object.keys(
    movements,
  ) as (keyof WatchScanMovement)[]) {
    watch(movements[movement], async (value: number) => {
      await viewer3cr.scanMovementHandler(movement, value);
    });
  }
}