feat: medieval flat palette for the diorama models, forest trees and a well
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
6b27906b6c
commit
d0a6487755
|
|
@ -12,16 +12,14 @@ export interface Face {
|
||||||
color: string
|
color: string
|
||||||
/** Planes like fields and banners: shown from either side. */
|
/** Planes like fields and banners: shown from either side. */
|
||||||
twoSided?: boolean
|
twoSided?: boolean
|
||||||
/** Skip light shading, e.g. for glowing fire. */
|
/** Skip light shading, e.g. for fire. */
|
||||||
flat?: boolean
|
flat?: boolean
|
||||||
opacity?: number
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Poly {
|
export interface Poly {
|
||||||
points: string
|
points: string
|
||||||
fill: string
|
fill: string
|
||||||
stroke: string
|
stroke: string
|
||||||
opacity: number
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const VIEW: V3 = [1, 1, 1]
|
const VIEW: V3 = [1, 1, 1]
|
||||||
|
|
@ -126,7 +124,6 @@ export function toPolys(faces: Face[], offset: V3 = [0, 0, 0]): Poly[] {
|
||||||
points: pts.map((p) => project(p).map((v) => v.toFixed(1)).join(',')).join(' '),
|
points: pts.map((p) => project(p).map((v) => v.toFixed(1)).join(',')).join(' '),
|
||||||
fill,
|
fill,
|
||||||
stroke: scale(fill, 0.86),
|
stroke: scale(fill, 0.86),
|
||||||
opacity: f.opacity ?? 1,
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -258,8 +255,8 @@ export function log(cx: number, cy: number, z: number, len: number, r: number, c
|
||||||
}
|
}
|
||||||
|
|
||||||
/** A flat, two-sided quad on the ground (fields, pits, paths) or upright (banners). */
|
/** A flat, two-sided quad on the ground (fields, pits, paths) or upright (banners). */
|
||||||
export function plane(pts: V3[], color: string, opacity?: number): Face {
|
export function plane(pts: V3[], color: string): Face {
|
||||||
return { pts, color, twoSided: true, opacity }
|
return { pts, color, twoSided: true }
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Every face moved by (dx, dy, dz). */
|
/** Every face moved by (dx, dy, dz). */
|
||||||
|
|
|
||||||
|
|
@ -4,38 +4,44 @@
|
||||||
// stone and bigger at high levels.
|
// stone and bigger at high levels.
|
||||||
|
|
||||||
import type { BuildingType } from '~/types/game'
|
import type { BuildingType } from '~/types/game'
|
||||||
import { box, type Face, hash, house, log, ngon, plane, prism, pyramid, rect, shift, type V2, type V3 } from './iso'
|
import { box, type Face, hash, house, log, ngon, orient, plane, prism, pyramid, rect, shift, type V2, type V3 } from './iso'
|
||||||
|
|
||||||
|
/** Muted medieval colours, all flat: faces get their light from iso.ts shading only. */
|
||||||
export const C = {
|
export const C = {
|
||||||
wood: '#b98552',
|
wood: '#8a5f38',
|
||||||
woodDark: '#8d5f36',
|
woodDark: '#6a4526',
|
||||||
plank: '#cfa16a',
|
plank: '#a67c4e',
|
||||||
thatch: '#d9b65f',
|
thatch: '#b8984f',
|
||||||
canvas: '#ece2ca',
|
canvas: '#d6c7a0',
|
||||||
canvasDark: '#d7c6a2',
|
canvasDark: '#b9a77f',
|
||||||
roofRed: '#b9573c',
|
roofRed: '#94452c',
|
||||||
slate: '#6a7482',
|
slate: '#575c63',
|
||||||
stone: '#b9b3a8',
|
stone: '#a39d92',
|
||||||
stoneDark: '#948e85',
|
stoneDark: '#847e74',
|
||||||
field: '#a8c65e',
|
field: '#8c9a4c',
|
||||||
wheat: '#e3c45f',
|
wheat: '#c4a552',
|
||||||
furrow: '#c9a24e',
|
furrow: '#9a7c44',
|
||||||
soil: '#9c744a',
|
soil: '#7d5c3a',
|
||||||
leaf: '#5f9c46',
|
leaf: '#56703a',
|
||||||
leafDark: '#4b8439',
|
leafDark: '#3f5a2c',
|
||||||
trunk: '#7b5333',
|
trunk: '#5a3d24',
|
||||||
clay: '#cc7a4f',
|
clay: '#a8643f',
|
||||||
clayDark: '#a65a37',
|
clayDark: '#874c2f',
|
||||||
clayWet: '#b9683f',
|
clayWet: '#96583a',
|
||||||
rock: '#8e8983',
|
rock: '#8a857d',
|
||||||
ore: '#5e6a78',
|
ore: '#4f5a63',
|
||||||
fire: '#f4a53b',
|
fire: '#d98a2b',
|
||||||
banner: '#b9443a',
|
banner: '#7b1e16',
|
||||||
hay: '#e6cb6c',
|
hay: '#c9ad5e',
|
||||||
cloth: '#7a5f4a',
|
cloth: '#6b4f3a',
|
||||||
skin: '#e7bb92',
|
skin: '#d8a982',
|
||||||
dark: '#3e342b',
|
dark: '#2f2620',
|
||||||
grass: '#86b456',
|
grass: '#78894a',
|
||||||
|
conifer: '#3d5a2b',
|
||||||
|
coniferDark: '#334d25',
|
||||||
|
broadleaf: '#5a7339',
|
||||||
|
broadleafDark: '#4c6431',
|
||||||
|
bush: '#5f7a3c',
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Model {
|
export interface Model {
|
||||||
|
|
@ -82,12 +88,56 @@ export function tree(x: number, y: number, size: number, seed = 0): Face[] {
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
export function rock(x: number, y: number, size: number, seed = 0): Face[] {
|
export function rock(x: number, y: number, size: number, seed = 0, color = C.rock): Face[] {
|
||||||
const base = ngon(x, y, size * 0.5, 5, hash(seed, 1) * 6).map(([px, py], i): V2 => {
|
const base = ngon(x, y, size * 0.5, 5, hash(seed, 1) * 6).map(([px, py], i): V2 => {
|
||||||
const k = 0.75 + 0.45 * hash(seed, i)
|
const k = 0.75 + 0.45 * hash(seed, i)
|
||||||
return [x + (px - x) * k, y + (py - y) * k]
|
return [x + (px - x) * k, y + (py - y) * k]
|
||||||
})
|
})
|
||||||
return pyramid(base, 0, size * (0.45 + 0.3 * hash(seed, 9)), C.rock, [x + size * 0.08, y - size * 0.06])
|
return pyramid(base, 0, size * (0.45 + 0.3 * hash(seed, 9)), color, [x + size * 0.08, y - size * 0.06])
|
||||||
|
}
|
||||||
|
|
||||||
|
// Landscape: lighter trees for the forest around the village (few faces each).
|
||||||
|
|
||||||
|
/** A fir: one tall faceted cone on a short trunk. */
|
||||||
|
export function conifer(x: number, y: number, size: number, seed = 0): Face[] {
|
||||||
|
const rot = hash(seed, 7) * Math.PI
|
||||||
|
const color = hash(seed, 3) > 0.5 ? C.conifer : C.coniferDark
|
||||||
|
return [
|
||||||
|
...prism(ngon(x, y, size * 0.07, 4, rot), 0, size * 0.25, C.trunk),
|
||||||
|
...pyramid(ngon(x, y, size * 0.36, 5, rot), size * 0.18, size * 1.05, color),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A deciduous tree: a faceted crown (two pyramids back to back) on a trunk. */
|
||||||
|
export function broadleaf(x: number, y: number, size: number, seed = 0): Face[] {
|
||||||
|
const rot = hash(seed, 5) * Math.PI
|
||||||
|
const color = hash(seed, 4) > 0.5 ? C.broadleaf : C.broadleafDark
|
||||||
|
const ring = ngon(x, y, size * 0.4, 5, rot)
|
||||||
|
const mid = size * 0.62
|
||||||
|
// Downward cone under the crown, flipped so its faces point outwards.
|
||||||
|
const bottom = pyramid(ring, mid, -size * 0.3, color).map((f) => ({ ...f, pts: orient(f.pts, [x, y, mid]) }))
|
||||||
|
return [
|
||||||
|
...prism(ngon(x, y, size * 0.07, 4, rot), 0, size * 0.36, C.trunk),
|
||||||
|
...bottom,
|
||||||
|
...pyramid(ring, mid, size * 0.42, color),
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
export function bush(x: number, y: number, size: number, seed = 0): Face[] {
|
||||||
|
return pyramid(ngon(x, y, size * 0.4, 5, hash(seed, 2) * 6), 0, size * 0.35, C.bush)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The village well on the plaza. */
|
||||||
|
export function well(s: number): Model {
|
||||||
|
return {
|
||||||
|
faces: [
|
||||||
|
...prism(ngon(0, 0, s * 0.42, 8), 0, s * 0.32, C.stone, C.dark),
|
||||||
|
...post(-s * 0.36, 0, s * 0.85, s * 0.05),
|
||||||
|
...post(s * 0.36, 0, s * 0.85, s * 0.05),
|
||||||
|
...house(0, 0, s * 0.95, s * 0.55, s * 0.85, s * 0.3, C.woodDark, C.roofRed, 'x').slice(5),
|
||||||
|
],
|
||||||
|
height: s * 1.2,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function person(x: number, y: number, s: number, shirt = C.cloth): Face[] {
|
function person(x: number, y: number, s: number, shirt = C.cloth): Face[] {
|
||||||
|
|
@ -418,7 +468,7 @@ const models: Record<BuildingType, (s: number, t: number) => Model> = {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// The wall is drawn as the ring around the plateau, see scene.ts.
|
// The wall is drawn as the ring around the village, see scene.ts.
|
||||||
wall: () => ({ faces: [], height: 0 }),
|
wall: () => ({ faces: [], height: 0 }),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -431,7 +481,7 @@ export function scaffold(s: number): Model {
|
||||||
const a = s * 0.6
|
const a = s * 0.6
|
||||||
return {
|
return {
|
||||||
faces: [
|
faces: [
|
||||||
plane(rect(0, 0, a * 2.1, a * 2.1).map(([x, y]) => [x, y, 0.5]), C.soil, 0.5),
|
plane(rect(0, 0, a * 2.1, a * 2.1).map(([x, y]) => [x, y, 0.5]), C.soil),
|
||||||
...post(-a, -a, s * 0.75, s * 0.035),
|
...post(-a, -a, s * 0.75, s * 0.035),
|
||||||
...post(a, -a, s * 0.75, s * 0.035),
|
...post(a, -a, s * 0.75, s * 0.035),
|
||||||
...post(-a, a, s * 0.75, s * 0.035),
|
...post(-a, a, s * 0.75, s * 0.035),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue