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.
39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
import { Color } from 'three'
|
|
|
|
import { MEDIEVAL_PALETTE, type MedievalPalette } from './materials.ts'
|
|
import { jitter } from './random.ts'
|
|
|
|
/**
|
|
* Factory that produces colours deviated from the palette.
|
|
*
|
|
* Every model used to rewrite this inline — the same five lines thirteen
|
|
* times. The cost of the repetition was not just line count: the deviation
|
|
* amounts had drifted from model to model, so when two models were put side
|
|
* by side one of them visibly had more variation than the other.
|
|
*
|
|
* The returned Color IS THE SAME OBJECT ON EVERY CALL. That is not a problem
|
|
* because the geometry functions read the colour immediately and write it into
|
|
* the vertices, and it is far cheaper than allocating one Color per call. But
|
|
* anyone who wants to keep it must do `new Color(tint(...))` — otherwise the
|
|
* next call mutates what they are holding.
|
|
*/
|
|
export function createTinter(random: () => number) {
|
|
const scratch = new Color()
|
|
return (
|
|
key: keyof MedievalPalette,
|
|
/** Lightness shift. Negative darkens. */
|
|
lift = 0,
|
|
/** Deviation multiplier. 0 gives a completely flat colour. */
|
|
spread = 1,
|
|
): Color => {
|
|
scratch.copy(MEDIEVAL_PALETTE[key])
|
|
scratch.offsetHSL(
|
|
jitter(random, 0.012 * spread),
|
|
jitter(random, 0.05 * spread),
|
|
lift + jitter(random, 0.05 * spread),
|
|
)
|
|
return scratch
|
|
}
|
|
}
|
|
|
|
export type Tinter = ReturnType<typeof createTinter>
|