| 1 |
import * as THREE from "three"; |
| 2 |
import {expect, test} from "vitest"; |
| 3 |
|
| 4 |
import {CAMERA_FRUSTUM_COLORS, COORDINATE_COLORS, photometricPointColor, scaleFromNativeWheel} from "../viewer_src/viewer"; |
| 5 |
|
| 6 |
test("matches native COLMAP camera frustum colors", () => { |
| 7 |
expect(CAMERA_FRUSTUM_COLORS).toEqual({ |
| 8 |
frame: [0.8, 0.1, 0, 1], |
| 9 |
plane: [1, 0.1, 0, 0.6], |
| 10 |
selectedFrame: [0.8, 0, 0.8, 1], |
| 11 |
selectedPlane: [1, 0, 1, 0.6], |
| 12 |
sameFrame: [0.6, 0, 0.6, 179 / 255], |
| 13 |
sameFramePlane: [0.8, 0, 0.8, 77 / 255], |
| 14 |
}); |
| 15 |
}); |
| 16 |
|
| 17 |
test("matches native COLMAP coordinate overlay colors", () => { |
| 18 |
expect(COORDINATE_COLORS).toEqual({ |
| 19 |
grid: [51 / 255, 51 / 255, 51 / 255, 153 / 255], |
| 20 |
x: [230 / 255, 0, 0, 128 / 255], |
| 21 |
y: [0, 230 / 255, 0, 128 / 255], |
| 22 |
z: [0, 0, 230 / 255, 128 / 255], |
| 23 |
}); |
| 24 |
}); |
| 25 |
|
| 26 |
test("matches native modifier-wheel scaling and limits", () => { |
| 27 |
expect(scaleFromNativeWheel(1, -120, 0, 0.5, 100)).toBeCloseTo(1.12); |
| 28 |
expect(scaleFromNativeWheel(1, 120, 0, 0.5, 100)).toBeCloseTo(0.88); |
| 29 |
expect(scaleFromNativeWheel(0.5, 1000, 0, 0.5, 100)).toBe(0.5); |
| 30 |
expect(scaleFromNativeWheel(100, -1000, 0, 0.5, 100)).toBe(100); |
| 31 |
}); |
| 32 |
|
| 33 |
test("preserves COLMAP photometric RGB values through Three.js color management", () => { |
| 34 |
expect(photometricPointColor([115, 121, 122]).getHex(THREE.SRGBColorSpace)).toBe(0x73797a); |
| 35 |
}); |