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.
26 lines
902 B
TypeScript
26 lines
902 B
TypeScript
/**
|
|
* Deterministik rastgelelik.
|
|
*
|
|
* Prosedürel bir kitte varyasyon şart — mükemmel simetri "üretilmiş" gibi
|
|
* okunur. Ama varyasyon tekrarlanabilir olmalı: aynı seed her zaman aynı
|
|
* modeli vermeli, yoksa ne önizleme, ne test, ne de sanat yönetimi tutar.
|
|
* Math.random() bu yüzden kullanılmıyor.
|
|
*
|
|
* mulberry32: 32-bit durum, hızlı, kriptografik değil ama görsel varyasyon
|
|
* için fazlasıyla yeterli.
|
|
*/
|
|
export function createRandom(seed: number): () => number {
|
|
let state = seed >>> 0
|
|
return () => {
|
|
state = (state + 0x6d2b79f5) >>> 0
|
|
let t = state
|
|
t = Math.imul(t ^ (t >>> 15), t | 1)
|
|
t ^= t + Math.imul(t ^ (t >>> 7), t | 61)
|
|
return ((t ^ (t >>> 14)) >>> 0) / 4294967296
|
|
}
|
|
}
|
|
|
|
/** -amount .. +amount aralığında simetrik sapma. */
|
|
export function jitter(random: () => number, amount: number): number {
|
|
return (random() * 2 - 1) * amount
|
|
}
|