28 lines
1.4 KiB
JavaScript
28 lines
1.4 KiB
JavaScript
import assert from 'node:assert/strict'
|
|
import { writeFileSync, mkdirSync } from 'node:fs'
|
|
import { model, exportOBJ, partFaces, profileVertices } from '../src/model/geometry.js'
|
|
const faces = model.parts.flatMap(partFaces)
|
|
assert.equal(faces.length, 468)
|
|
assert.equal(model.connection.status, '확인 필요')
|
|
for (const part of model.parts) {
|
|
const a = profileVertices(part, 0), b = profileVertices(part, 1)
|
|
assert.equal(a.length,b.length)
|
|
for(let i=0;i<a.length;i++) {
|
|
assert.ok(Math.abs(b[i][2]-a[i][2]-19.98)<1e-10)
|
|
assert.equal(a[i][0],part.a[i][0]); assert.equal(b[i][0],part.b[i][0])
|
|
assert.ok(Math.abs(a[i][1]+100-part.a[i][1])<1e-10)
|
|
assert.ok(Math.abs(b[i][1]+100-part.b[i][1])<1e-10)
|
|
}
|
|
}
|
|
const obj=exportOBJ()
|
|
const rows=obj.split('\n'), vertices=rows.filter(r=>r.startsWith('v '))
|
|
assert.equal(rows.filter(r=>r.startsWith('o ')).length,154)
|
|
assert.equal(rows.filter(r=>r.startsWith('f ')).length,468)
|
|
for(const row of rows.filter(r=>r.startsWith('f ')||r.startsWith('l '))) {
|
|
for(const n of row.split(' ').slice(1)) assert.ok(Number(n)>=1&&Number(n)<=vertices.length)
|
|
}
|
|
assert.equal(exportOBJ(new Set(model.parts.map(p=>p.id))).split('\n').filter(r=>r.startsWith('v ')).length,0)
|
|
mkdirSync('public/models',{recursive:true})
|
|
writeFileSync('public/models/BLOCK7_검토용모델.obj',obj)
|
|
console.log('직선 연결 19.980m, 468개 삼각면, 154개 객체, OBJ 참조·숨김 반영 검증 통과')
|