Files
Pier_v1/tests/all-piers.test.ts
T
ypshimandClaude Haiku 5.5 a2ad0f2baf feat(view): 전체 보기로 6기 콘크리트를 한 화면에 표시
- 교각별 축 위치(pivot E·N 차이)로 장면을 배치하는 pierOffset과 buildAllPiers 추가
- 지형 격자는 기준 교각(첫 교각) 좌표로 한 번만 그림, 교각별 지반면은 숨김
- 철근은 표시하지 않음 (콘크리트만). ① 형상 생성에서만 동작
- 전체 보기에서 교각을 클릭하면 그 교각을 활성으로 하고 단일 교각 보기로 전환
- 테스트: 위치 오프셋 부호, 피벗을 옮겨도 같은 월드 상자

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-10-27 15:08:09 +09:00

42 lines
1.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import * as THREE from 'three';
import { describe, expect, it } from 'vitest';
import { buildPier, type PierModel } from '../src/core/geometry';
import { buildAllPiers, pierOffset } from '../src/view/all-piers';
import { loadP1 } from './helpers';
const model = buildPier(loadP1());
describe('pierOffset', () => {
it('is zero for the reference pier', () => {
expect(pierOffset(model.pivot, model.pivot)).toEqual({ x: 0, z: 0 });
});
it('moves east by the E difference and north by the N difference (z = −N)', () => {
const ref = { e: 259865, n: 179138 };
const other = { e: 260117, n: 179177 };
expect(pierOffset(other, ref)).toEqual({ x: 252, z: -39 });
});
});
describe('buildAllPiers', () => {
it('places a pier at the same world box whatever pivot it is built around', () => {
// The same pier with its pivot shifted: the geometry shifts by the opposite amount, so the world box must not change.
const shifted: PierModel = { ...model, pivot: { e: model.pivot.e + 50, n: model.pivot.n - 20 } };
const all = buildAllPiers([{ name: 'P1', model }, { name: 'P2', model: shifted }]);
all.piers.updateMatrixWorld(true);
const a = new THREE.Box3().setFromObject(all.scenes.get('P1')!.root);
const b = new THREE.Box3().setFromObject(all.scenes.get('P2')!.root);
// Float32 geometry: allow 0.1 mm.
expect(b.min.distanceTo(a.min)).toBeLessThan(1e-4);
expect(b.max.distanceTo(a.max)).toBeLessThan(1e-4);
});
it('hides each pier ground plane and keys scenes by name', () => {
const all = buildAllPiers([{ name: 'P1', model }]);
expect([...all.scenes.keys()]).toEqual(['P1']);
expect(all.scenes.get('P1')!.parts.ground.visible).toBe(false);
expect(all.terrain).toBeNull();
expect(all.view.size).toBeGreaterThan(0);
});
});