46 lines
2.6 KiB
TypeScript
46 lines
2.6 KiB
TypeScript
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);
|
||
});
|
||
|
||
it('the 교량받침 본체 is one box per bearing: the solplate plan less 100 mm on each side, height h3 (181 mm)', () => {
|
||
const m = buildPier({ ...loadP1(), bearingPlans: plans, solplate: { T: 30, margin: 100, h3: 181 } });
|
||
const scene = buildPierScene(m);
|
||
const bodies = scene.parts.bearings.children;
|
||
expect(bodies.length).toBe(10);
|
||
const one = new THREE.Box3().setFromObject(bodies[0]);
|
||
expect(one.max.y - one.min.y).toBeCloseTo(0.181, 3);
|
||
// Body 1: L = 800 − 200 = 600 across the 교각축 직각, W = 740 − 200 = 540 along the 교축; the row skew turns it a few degrees.
|
||
expect(Math.max(one.max.x - one.min.x, one.max.z - one.min.z)).toBeGreaterThan(0.54);
|
||
});
|
||
});
|