Files
Pier_v1/tests/scene.test.ts
T
ypshimandClaude Haiku 5.5 36b26209df feat(bearing): 솔플레이트 규칙을 교각별 입력으로 바꾸고 도면 불러오기 제거 (C안)
- 받침 기준 카드, 도면 불러오기(xlsx·csv·dxf), 도면 참조 표·오버레이 제거
- 교각마다 솔플레이트 규칙 입력: 받침높이 H(솔플레이트 포함) 211, 교직 L 1000,
  교축 W 1100, 종단 기울기 S −0.5 % (기본값, 가정 표시)
- 중심 두께 T = ⌈22 + L·|S|/200⌉ 로 계산해 얇은 쪽 T2가 22 mm 이상이 되게 함
  (기본값 T 25, T2 22.5, h3 = H − T = 186)
- geometry·scene·SVG는 교각 규칙에서 만든 같은 솔플레이트 계획을 모든 받침에 사용

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
2026-11-03 11:07:51 +09:00

52 lines
2.1 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 } from '../src/core/geometry';
import { buildPierScene, frameMatrix } from '../src/view/scene';
import { loadP1 } from './helpers';
const model = buildPier(loadP1());
const M = frameMatrix(model);
/** Scene coordinates of a national-grid point at EL 0 (x = E − pivot E, z = −(N − pivot N)). */
function sceneOf(e: number, n: number, el: number): THREE.Vector3 {
return new THREE.Vector3(e - model.pivot.e, el, -(n - model.pivot.n));
}
describe('3D frame (view/scene.ts)', () => {
it('is a proper rotation (determinant +1) so faces keep their winding', () => {
expect(M.determinant()).toBeCloseTo(1, 9);
});
it('maps local (along-axis s, across n, EL) to the national-grid position', () => {
// Block 1 on the front row: its centre in grid coordinates must match the local-to-grid formula.
const b = model.blocks[0];
const grid = {
e: model.bp1.e + model.u.e * b.s + model.nrm.e * b.n,
n: model.bp1.n + model.u.n * b.s + model.nrm.n * b.n,
};
const mapped = new THREE.Vector3(b.s, b.bottom, b.n).applyMatrix4(M);
const expected = sceneOf(grid.e, grid.n, b.bottom);
expect(mapped.distanceTo(expected)).toBeLessThan(1e-6);
});
it('bounding box spans pile tip (2.208 m) to the highest solplate top (back bearing 5: pad top 43.898 m + h3 0.186 m + T1 0.0275 m)', () => {
const scene = buildPierScene(model);
const box = new THREE.Box3().setFromObject(scene.root);
expect(box.min.y).toBeCloseTo(2.208, 2);
expect(box.max.y).toBeCloseTo(43.898 + 0.186 + 0.0275, 3);
});
it('builds the expected part counts for P1', () => {
const scene = buildPierScene(model);
const count = (key: keyof typeof scene.parts) => scene.parts[key].children.length;
expect(count('coping')).toBe(1);
expect(count('columns')).toBe(1);
expect(count('footings')).toBe(1);
expect(count('piles')).toBe(20);
expect(count('blocks')).toBe(10);
expect(count('pads')).toBe(10);
expect(count('blinding')).toBe(1);
expect(count('ground')).toBe(1);
});
});