A lowpoly medieval procedural model library for Vibe3D, plus the model inspector used to build it. Registry (@medieval-kit, published as @medieval-kit/registry): - core: deterministic mulberry32 RNG, slot-based vertex-coloured materials, a geometry vocabulary (box, prism, stave, band, head, flip), and the stable-anchor part slots the Vibe3D protocol requires - wooden-barrel: 806 tris, 13 separate staves, iron hoops, recessed heads - wooden-crate: 360 tris, plank rows on corner posts, forged straps - iron-brazier: 423 tris, typed actions, per-frame flame flicker, own light The kit declares no renderer capabilities, so it runs on WebGLRenderer as well as WebGPURenderer. Colour variation lives in vertex attributes rather than in materials, so each model keeps one draw call per material. Verification (bun run verify) covers 64 checks without a browser: geometry validity, winding by two measures (radial alignment for bodies of revolution, signed volume for closed solids), coplanar-face detection for z-fighting, stable root and anchor identity across configure(), deterministic seeding, material ownership, and idempotent disposal.
49 lines
1.8 KiB
TypeScript
49 lines
1.8 KiB
TypeScript
/**
|
|
* dist-viewer/ çıktısını tek dosyalık, kendi kendine yeten bir HTML'e indirger.
|
|
*
|
|
* Artifact sayfaları katı bir CSP altında çalışır: harici host'a istek yok.
|
|
* Tek istisna Google Fonts. Bu yüzden JS ve CSS gömülü olmak zorunda.
|
|
*
|
|
* Çalıştır:
|
|
* bunx vite build --config vite.viewer.config.ts
|
|
* bun scripts/build-artifact.ts
|
|
*/
|
|
import { readFile, writeFile } from 'node:fs/promises'
|
|
import { dirname, join, resolve } from 'node:path'
|
|
import { fileURLToPath } from 'node:url'
|
|
|
|
const projectRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..')
|
|
const distRoot = join(projectRoot, 'dist-viewer')
|
|
|
|
// Sadece gerçekten kullanılan ağırlıklar. Google Fonts her ağırlığı tembel
|
|
// yükler; istemediğiniz ağırlıkları istemek boşuna CSS büyütür.
|
|
const FONTS =
|
|
'https://fonts.googleapis.com/css2?family=Archivo:wght@400;700' +
|
|
'&family=IBM+Plex+Mono:wght@400;500;600&display=swap'
|
|
|
|
const css = await readFile(join(distRoot, 'viewer.css'), 'utf8')
|
|
const js = await readFile(join(distRoot, 'viewer.js'), 'utf8')
|
|
|
|
// Gömülü script içindeki bir `</script` dizisi HTML ayrıştırıcısını erken
|
|
// kapatırdı. Bu kaçış JavaScript anlamını değiştirmez.
|
|
const safeJs = js.replaceAll('</script', String.raw`<\/script`)
|
|
|
|
const html = `<title>vibe3d Model Tezgahı</title>
|
|
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
<link rel="stylesheet" href="${FONTS}" />
|
|
<style>
|
|
${css}
|
|
</style>
|
|
<div id="app"></div>
|
|
<script type="module">
|
|
${safeJs}
|
|
</script>
|
|
`
|
|
|
|
const output = join(distRoot, 'artifact.html')
|
|
await writeFile(output, html, 'utf8')
|
|
|
|
const kb = (value: number) => `${(value / 1024).toFixed(0)} KB`
|
|
console.log(`dist-viewer/artifact.html yazıldı`)
|
|
console.log(` CSS ${kb(css.length)} · JS ${kb(js.length)} · toplam ${kb(html.length)}`)
|