medieval-kit/scripts/catalog-table.ts
CRT 4a75046cac Translate the whole repository to English
The kit is going public, so everything a reader sees is now English:
27 model sources, the core vocabulary, meta.ts (titles, descriptions and
every slider label), the viewer UI, all script output, REFERENCE.md and
the READMEs.

Rules applied: only comments, doc comments and human-facing strings were
touched. Identifiers, numbers, logic, registry item ids, part names and
material slot names are unchanged — those are a published contract and
were already English.

Verified rather than assumed: for all 53 changed .ts files the code
skeleton (source with comments stripped and string contents replaced by a
placeholder) is byte-identical before and after. Full gate is green —
typecheck, registry conformance, ~510 model checks, GLB round trip and a
production build.

Also fixed here:
- index.html and viewer.html were missed by the translation pass because
  the file list only covered .ts/.md/.css. Both had lang="tr" and Turkish
  titles.
- The viewer formatted triangle counts with toLocaleString('tr-TR'), which
  prints 15.425 rather than 15,425.
- REFERENCE.md's model table header did not match what
  scripts/catalog-table.ts emits, so the next regeneration would have
  silently changed it. Aligned to the generator.
- Removed scripts/probe.ts and scripts/zdiag.ts; they were throwaway
  diagnostics that got committed by accident.
2026-08-21 07:35:13 +00:00

48 lines
1.7 KiB
TypeScript

/**
* Generates the model table in REFERENCE.md.
*
* A hand-written table goes stale the moment the first model is added — and it
* had gone stale: the document said "four items" while the kit had twenty-three.
* The table is now read from the models THEMSELVES, so for it to be wrong the
* model itself has to be broken.
*
* bun scripts/catalog-table.ts
*/
import { Box3, Mesh } from 'three/webgpu'
import { MODEL_META } from '../my-registry/meta.ts'
import { CATALOG } from '@/catalog.ts'
const rows: string[] = []
let total = 0
const slots = new Set<string>()
for (const id of Object.keys(CATALOG)) {
const meta = MODEL_META[id]
if (!meta) continue
const built = CATALOG[id]!.build()
let triangles = 0
built.root.traverse((object) => {
if (!(object instanceof Mesh)) return
const index = object.geometry.getIndex()
triangles += (index ? index.count : object.geometry.getAttribute('position').count) / 3
})
const box = new Box3().setFromObject(built.root)
const size = box.getSize(box.max.clone())
const animated = built.action !== undefined
built.dispose()
for (const slot of meta.materialSlots) slots.add(slot)
total += triangles
const dims = `${size.x.toFixed(2)}×${size.y.toFixed(2)}×${size.z.toFixed(2)}`
rows.push(
`| \`${id}\` | ${meta.category} | ${triangles} | ${meta.parts.length} | ${dims} | `
+ `${meta.materialSlots.join(', ')} | ${animated ? '✔' : ''} |`,
)
}
console.log('| Model | Category | Triangles | Parts | Size (m) | Material slots | Animated |')
console.log('| --- | --- | ---: | ---: | --- | --- | :-: |')
console.log(rows.join('\n'))
console.log(`\n${rows.length} models · ${total} triangles · ${slots.size} material slots`)