import { describe, expect, it } from 'vitest'; import * as THREE from 'three'; import { buildPier } from '../src/core/geometry'; import { solplateGeometry } from '../src/core/solplate'; import { BEARING_ELEVATION_REF, SOLPLATE_REF } from '../src/core/bearing-ref'; import { buildPierScene } from '../src/view/scene'; import { loadP1 } from './helpers'; const plans = SOLPLATE_REF.map((s, i) => ({ no: s.no, A: BEARING_ELEVATION_REF[i].A, B: BEARING_ELEVATION_REF[i].B, S: s.s })); describe('솔플레이트 모델과 3D (2단계, 승인 2026-10-23)', () => { it('without plans there is no solplate; with plans every bearing has one', () => { expect(buildPier(loadP1()).blocks.every((b) => b.plan === undefined)).toBe(true); const m = buildPier({ ...loadP1(), bearingPlans: plans, solplate: { T: 30, margin: 100, h3: 181 } }); expect(m.blocks.every((b) => b.plan !== undefined)).toBe(true); expect(m.blocks[0].plan!.A).toBe(700); }); it('the 3D scene has one solplate wedge per bearing, and its height is the bearing top plus T', () => { const m = buildPier({ ...loadP1(), bearingPlans: plans, solplate: { T: 30, margin: 100, h3: 181 } }); const scene = buildPierScene(m); const wedges = scene.parts.solplates.children; expect(wedges.length).toBe(10); const box = new THREE.Box3().setFromObject(scene.parts.solplates); // The highest point is the thick (시점) end of the tallest wedge: underside (block top + h3) + T1. const top = Math.max(...m.blocks.map((b) => solplateGeometry(b, 181, { A: b.plan!.A, B: b.plan!.B, margin: 100, T: 30, slopePct: b.plan!.S }).bottom + solplateGeometry(b, 181, { A: b.plan!.A, B: b.plan!.B, margin: 100, T: 30, slopePct: b.plan!.S }).T1)); expect(box.max.y).toBeCloseTo(top, 3); }); it('without plans the scene has an empty solplate part', () => { const scene = buildPierScene(buildPier(loadP1())); expect(scene.parts.solplates.children.length).toBe(0); }); });