All files / core/src/RenderingEngine/GenericViewport/Planar planarMath.ts

0% Statements 0/5
0% Branches 0/9
0% Functions 0/2
0% Lines 0/5

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                                                   
import { vec3 } from 'gl-matrix';
import type { Point3 } from '../../../types';
 
export function getSafeCanvasDimension(value: number): number {
  return Math.max(value || 0, 1);
}
 
export function normalizePoint3(point: Point3, fallback?: Point3): Point3 {
  const normalized = vec3.normalize(
    vec3.create(),
    point as unknown as vec3
  ) as Point3;
 
  if (
    fallback &&
    (!Number.isFinite(normalized[0]) ||
      !Number.isFinite(normalized[1]) ||
      !Number.isFinite(normalized[2]) ||
      vec3.length(normalized as unknown as vec3) === 0)
  ) {
    return vec3.clone(fallback as unknown as vec3) as Point3;
  }
 
  return normalized;
}