fix: close phase 2 journey blockers
This commit is contained in:
@@ -1,6 +1,9 @@
|
||||
import { describe, expect, it, vi } from 'vitest';
|
||||
import * as THREE from 'three';
|
||||
import { SceneResourceBag } from '@/scene/resources';
|
||||
import { renderQualityFor } from '@/scene/render-quality';
|
||||
import { createChaseCamera } from '@/scene/world/environment';
|
||||
import { createCar } from '@/scene/world/car';
|
||||
import { routeLabelFor } from '@/scene/world/sign';
|
||||
|
||||
describe('SceneResourceBag', () => {
|
||||
@@ -109,4 +112,48 @@ describe('scene render quality', () => {
|
||||
expect(routeLabelFor('infrastructure')).toBe('03 / INFRASTRUCTURE');
|
||||
expect(routeLabelFor('contact')).toBe('07 / DESTINATION');
|
||||
});
|
||||
|
||||
it('keeps the chase car recognizably wide and fully inside the desktop view', () => {
|
||||
const resources = new SceneResourceBag();
|
||||
const camera = createChaseCamera(16 / 9);
|
||||
const car = createCar(resources);
|
||||
car.group.updateMatrixWorld(true);
|
||||
camera.updateMatrixWorld(true);
|
||||
const bounds = new THREE.Box3().setFromObject(car.group);
|
||||
const projected = boxCorners(bounds).map((point) => point.project(camera));
|
||||
const minX = Math.min(...projected.map((point) => point.x));
|
||||
const maxX = Math.max(...projected.map((point) => point.x));
|
||||
const minY = Math.min(...projected.map((point) => point.y));
|
||||
const maxY = Math.max(...projected.map((point) => point.y));
|
||||
|
||||
expect(maxX - minX).toBeGreaterThan(0.22);
|
||||
expect(minY).toBeGreaterThan(-0.98);
|
||||
expect(maxY).toBeLessThan(-0.15);
|
||||
const silhouette = car.group.getObjectByName('rear-silhouette');
|
||||
expect(silhouette).toBeDefined();
|
||||
const silhouetteBounds = new THREE.Box3().setFromObject(silhouette);
|
||||
expect(silhouetteBounds.max.x - silhouetteBounds.min.x).toBeGreaterThan(4);
|
||||
expect(Math.max(
|
||||
silhouette.material.color.r,
|
||||
silhouette.material.color.g,
|
||||
silhouette.material.color.b,
|
||||
)).toBeGreaterThan(0.12);
|
||||
resources.dispose();
|
||||
});
|
||||
});
|
||||
|
||||
function boxCorners(bounds: {
|
||||
min: { x: number; y: number; z: number };
|
||||
max: { x: number; y: number; z: number };
|
||||
}) {
|
||||
return [
|
||||
new THREE.Vector3(bounds.min.x, bounds.min.y, bounds.min.z),
|
||||
new THREE.Vector3(bounds.min.x, bounds.min.y, bounds.max.z),
|
||||
new THREE.Vector3(bounds.min.x, bounds.max.y, bounds.min.z),
|
||||
new THREE.Vector3(bounds.min.x, bounds.max.y, bounds.max.z),
|
||||
new THREE.Vector3(bounds.max.x, bounds.min.y, bounds.min.z),
|
||||
new THREE.Vector3(bounds.max.x, bounds.min.y, bounds.max.z),
|
||||
new THREE.Vector3(bounds.max.x, bounds.max.y, bounds.min.z),
|
||||
new THREE.Vector3(bounds.max.x, bounds.max.y, bounds.max.z),
|
||||
];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user