@wildshard/shard-format 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +4 -1
- package/src/format/detail-layer.ts +73 -0
- package/src/format/look-light.ts +31 -1
- package/src/format/look-render.ts +161 -0
- package/src/format/materialFamilies.ts +7 -3
- package/src/format/pool-surface.ts +86 -0
- package/src/format/populationEnvironment.ts +8 -6
- package/src/format/shardSchema.ts +6 -2
- package/src/format/water.ts +6 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wildshard/shard-format",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "The raw shardfile format: the spec, the validator and a validate CLI. The public, versioned contract every other repo builds on.",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"repository": {
|
|
@@ -105,6 +105,7 @@
|
|
|
105
105
|
"./declaredQuestPage": "./src/format/declaredQuestPage.ts",
|
|
106
106
|
"./deviceMemoryCost": "./src/format/deviceMemoryCost.ts",
|
|
107
107
|
"./director": "./src/format/director.ts",
|
|
108
|
+
"./detail-layer": "./src/format/detail-layer.ts",
|
|
108
109
|
"./directorDocument": "./src/format/directorDocument.ts",
|
|
109
110
|
"./directorStages": "./src/format/directorStages.ts",
|
|
110
111
|
"./directorWhen": "./src/format/directorWhen.ts",
|
|
@@ -242,6 +243,8 @@
|
|
|
242
243
|
"./postGraphLook": "./src/format/postGraphLook.ts",
|
|
243
244
|
"./postStack": "./src/format/postStack.ts",
|
|
244
245
|
"./look-light": "./src/format/look-light.ts",
|
|
246
|
+
"./look-render": "./src/format/look-render.ts",
|
|
247
|
+
"./pool-surface": "./src/format/pool-surface.ts",
|
|
245
248
|
"./practiceCourseRows": "./src/format/practiceCourseRows.ts",
|
|
246
249
|
"./preflight": "./src/format/preflight.ts",
|
|
247
250
|
"./presentation": "./src/format/presentation.ts",
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A PBR surface's procedural detail layer (meta TEMPLATES-CLEANROOM M4.11, J338 "procedural maxxing"): the texture a
|
|
3
|
+
* cleanroom paints on canvases (stone, slab, wood, moss), made in the shader from world position, so it costs no bytes
|
|
4
|
+
* and needs no UVs. Absent: a plain surface, as before (no default is filled, so older shard files keep their bytes).
|
|
5
|
+
*
|
|
6
|
+
* - `scale`: the pattern's feature size in metres (a stone's mottling, a moss clump).
|
|
7
|
+
* - `mottle`: how far the broad blotches swing the albedo (0 none, 1 from black to double).
|
|
8
|
+
* - `grain`: the fine speckle's share of the albedo.
|
|
9
|
+
* - `relief`: how much the pattern tilts the shading normal (bumps).
|
|
10
|
+
* - `moss`: an optional moss colour (sRGB) grown on up-facing faces by `amount` (0 none, 1 every top).
|
|
11
|
+
*
|
|
12
|
+
* Plain data and checks, no three.js.
|
|
13
|
+
*/
|
|
14
|
+
import {
|
|
15
|
+
exactOptional,
|
|
16
|
+
finite,
|
|
17
|
+
maxValue,
|
|
18
|
+
minValue,
|
|
19
|
+
number,
|
|
20
|
+
pipe,
|
|
21
|
+
strictObject,
|
|
22
|
+
tuple,
|
|
23
|
+
} from 'valibot'
|
|
24
|
+
|
|
25
|
+
import type { ExactOptionalSchema, GenericSchema } from 'valibot'
|
|
26
|
+
|
|
27
|
+
type Rgb = [number, number, number]
|
|
28
|
+
|
|
29
|
+
const NONE = 0
|
|
30
|
+
const FULL = 1
|
|
31
|
+
const SCALE_MIN = 0.02
|
|
32
|
+
const SCALE_MAX = 20
|
|
33
|
+
const RELIEF_MAX = 2
|
|
34
|
+
|
|
35
|
+
/** Moss on up-facing faces. */
|
|
36
|
+
interface DetailMoss {
|
|
37
|
+
colour: Rgb
|
|
38
|
+
amount: number
|
|
39
|
+
}
|
|
40
|
+
/** A procedural detail layer. */
|
|
41
|
+
interface DetailLayer {
|
|
42
|
+
scale: number
|
|
43
|
+
mottle: number
|
|
44
|
+
grain: number
|
|
45
|
+
relief: number
|
|
46
|
+
moss?: DetailMoss
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const real = pipe(number(), finite())
|
|
50
|
+
const range = (low: number, high: number): GenericSchema<number, number> =>
|
|
51
|
+
pipe(real, minValue(low), maxValue(high))
|
|
52
|
+
const unit = range(NONE, FULL)
|
|
53
|
+
const DetailMossSchema: GenericSchema<DetailMoss, DetailMoss> = strictObject({
|
|
54
|
+
colour: tuple([unit, unit, unit]),
|
|
55
|
+
amount: unit,
|
|
56
|
+
})
|
|
57
|
+
const DetailLayerSchema: GenericSchema<DetailLayer, DetailLayer> = strictObject(
|
|
58
|
+
{
|
|
59
|
+
scale: range(SCALE_MIN, SCALE_MAX),
|
|
60
|
+
mottle: unit,
|
|
61
|
+
grain: unit,
|
|
62
|
+
relief: range(NONE, RELIEF_MAX),
|
|
63
|
+
moss: exactOptional(DetailMossSchema),
|
|
64
|
+
},
|
|
65
|
+
)
|
|
66
|
+
/** The PBR family's optional `detail` key. */
|
|
67
|
+
const detailLayer: ExactOptionalSchema<
|
|
68
|
+
GenericSchema<DetailLayer, DetailLayer>,
|
|
69
|
+
undefined
|
|
70
|
+
> = exactOptional(DetailLayerSchema)
|
|
71
|
+
|
|
72
|
+
export { DetailLayerSchema, DetailMossSchema, detailLayer }
|
|
73
|
+
export type { DetailLayer, DetailMoss }
|
package/src/format/look-light.ts
CHANGED
|
@@ -18,6 +18,9 @@
|
|
|
18
18
|
* `look.grade.tone` (B2) picks the display curve: `agx` (absent: the engine's AgX, as before) or `neutral` (Khronos PBR
|
|
19
19
|
* Neutral, which keeps saturated albedo saturated).
|
|
20
20
|
*
|
|
21
|
+
* `look.light.shadow` and `motes`, a lamp's `decay`, `halo` and `flicker`, `grade.vignette`, `grade.bloom.radius` and
|
|
22
|
+
* `tone: 'aces'` (meta TEMPLATES-CLEANROOM M4) are in `look-render.ts`.
|
|
23
|
+
*
|
|
21
24
|
* Plain data and checks, no three.js. Absent keys stay absent (no filled default), so a product built before these keys
|
|
22
25
|
* parses to the same bytes and keeps its source hash.
|
|
23
26
|
*/
|
|
@@ -36,6 +39,20 @@ import {
|
|
|
36
39
|
tuple,
|
|
37
40
|
} from 'valibot'
|
|
38
41
|
|
|
42
|
+
import {
|
|
43
|
+
LookMotesSchema,
|
|
44
|
+
LookShadowSchema,
|
|
45
|
+
lampDecay,
|
|
46
|
+
lampFlicker,
|
|
47
|
+
lampHalo,
|
|
48
|
+
} from './look-render.ts'
|
|
49
|
+
|
|
50
|
+
import type {
|
|
51
|
+
LookLampFlicker,
|
|
52
|
+
LookLampHalo,
|
|
53
|
+
LookMotes,
|
|
54
|
+
LookShadow,
|
|
55
|
+
} from './look-render.ts'
|
|
39
56
|
import type { GenericSchema } from 'valibot'
|
|
40
57
|
|
|
41
58
|
type Rgb = [number, number, number]
|
|
@@ -96,6 +113,9 @@ interface LookLamp {
|
|
|
96
113
|
colour: Rgb
|
|
97
114
|
intensity: number
|
|
98
115
|
distance: number
|
|
116
|
+
decay?: number
|
|
117
|
+
halo?: LookLampHalo
|
|
118
|
+
flicker?: LookLampFlicker
|
|
99
119
|
}
|
|
100
120
|
/** A warm fill from the ground: a shadowless directional light from the anti-sun heading, lifted by `lift`. */
|
|
101
121
|
interface LookBounce {
|
|
@@ -117,13 +137,16 @@ interface LookLight {
|
|
|
117
137
|
lamps?: LookLamp[]
|
|
118
138
|
bounce?: LookBounce
|
|
119
139
|
environment?: LookEnvironment
|
|
140
|
+
shadow?: LookShadow
|
|
141
|
+
motes?: LookMotes
|
|
120
142
|
}
|
|
121
143
|
/** `look.grade.tone`: the display curve; absent is the engine's AgX. */
|
|
122
|
-
type LookTone = 'agx' | 'neutral'
|
|
144
|
+
type LookTone = 'agx' | 'neutral' | 'aces'
|
|
123
145
|
/** `look.grade.bloom`: the engine bloom's intensity and luminance threshold. */
|
|
124
146
|
interface LookBloom {
|
|
125
147
|
intensity: number
|
|
126
148
|
threshold: number
|
|
149
|
+
radius?: number
|
|
127
150
|
}
|
|
128
151
|
type LookLightInput = LookLight
|
|
129
152
|
type LookBloomInput = LookBloom
|
|
@@ -164,6 +187,9 @@ const LookLampSchema: GenericSchema<LookLamp, LookLamp> = strictObject({
|
|
|
164
187
|
colour,
|
|
165
188
|
intensity: range(NONE, LAMP_INTENSITY_MAX),
|
|
166
189
|
distance: range(LAMP_DISTANCE_MIN, LAMP_DISTANCE_MAX),
|
|
190
|
+
decay: lampDecay,
|
|
191
|
+
halo: lampHalo,
|
|
192
|
+
flicker: lampFlicker,
|
|
167
193
|
})
|
|
168
194
|
const LookLampsSchema: GenericSchema<LookLamp[], LookLamp[]> = pipe(
|
|
169
195
|
array(LookLampSchema),
|
|
@@ -189,16 +215,20 @@ const LookLightSchema: GenericSchema<LookLight, LookLight> = strictObject({
|
|
|
189
215
|
lamps: exactOptional(LookLampsSchema),
|
|
190
216
|
bounce: exactOptional(LookBounceSchema),
|
|
191
217
|
environment: exactOptional(LookEnvironmentSchema),
|
|
218
|
+
shadow: exactOptional(LookShadowSchema),
|
|
219
|
+
motes: exactOptional(LookMotesSchema),
|
|
192
220
|
})
|
|
193
221
|
/** `look.grade.tone`: absent is AgX, as before. */
|
|
194
222
|
const LookToneSchema: GenericSchema<LookTone, LookTone> = picklist([
|
|
195
223
|
'agx',
|
|
196
224
|
'neutral',
|
|
225
|
+
'aces',
|
|
197
226
|
])
|
|
198
227
|
/** `look.grade.bloom`: absent is no bloom, as before. */
|
|
199
228
|
const LookBloomSchema: GenericSchema<LookBloom, LookBloom> = strictObject({
|
|
200
229
|
intensity: range(NONE, BLOOM_INTENSITY_MAX),
|
|
201
230
|
threshold: range(NONE, FULL),
|
|
231
|
+
radius: exactOptional(range(NONE, FULL)),
|
|
202
232
|
})
|
|
203
233
|
|
|
204
234
|
export {
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The render-match settings of a look (meta TEMPLATES-CLEANROOM M4): what a cleanroom three.js scene sets that a shard
|
|
3
|
+
* could not say before. Each is off when absent, and no default is filled, so an older shard file keeps its bytes.
|
|
4
|
+
*
|
|
5
|
+
* - `look.light.shadow`: the sun's shadow look: `intensity` (0 none, 1 black), the filter `radius` (texels) and the
|
|
6
|
+
* `normalBias` (metres) that keeps faces from shadowing themselves.
|
|
7
|
+
* - a lamp's `decay` (absent 2: physical), `halo` (a soft additive glow `size` metres across at `opacity`, one instanced
|
|
8
|
+
* draw for every halo) and `flicker` (`amount` of its intensity at about `rate` hertz: a fire's unsteady light).
|
|
9
|
+
* - `look.light.motes`: fireflies, sparks or dust: `count` glowing points drifting in the box `min`..`max`, in linear
|
|
10
|
+
* `colour` × `gain` (over 1 blooms), `size` metres across, one additive draw; phones draw half.
|
|
11
|
+
* - `look.grade.vignette`: the frame's dark edge, from `offset` (0 centre, 1 corner) at `darkness` (0 none); absent is
|
|
12
|
+
* the engine's own vignette.
|
|
13
|
+
*
|
|
14
|
+
* Plain data and checks, no three.js.
|
|
15
|
+
*/
|
|
16
|
+
import {
|
|
17
|
+
check,
|
|
18
|
+
exactOptional,
|
|
19
|
+
finite,
|
|
20
|
+
integer,
|
|
21
|
+
maxValue,
|
|
22
|
+
minValue,
|
|
23
|
+
number,
|
|
24
|
+
pipe,
|
|
25
|
+
strictObject,
|
|
26
|
+
tuple,
|
|
27
|
+
} from 'valibot'
|
|
28
|
+
|
|
29
|
+
import type { ExactOptionalSchema, GenericSchema } from 'valibot'
|
|
30
|
+
|
|
31
|
+
type Rgb = [number, number, number]
|
|
32
|
+
type Point = [number, number, number]
|
|
33
|
+
|
|
34
|
+
const NONE = 0
|
|
35
|
+
const FULL = 1
|
|
36
|
+
const SHADOW_RADIUS_MAX = 16
|
|
37
|
+
const SHADOW_NORMAL_BIAS_MAX = 0.5
|
|
38
|
+
const LAMP_DECAY_MAX = 2
|
|
39
|
+
const HALO_SIZE_MIN = 0.05
|
|
40
|
+
const HALO_SIZE_MAX = 8
|
|
41
|
+
const FLICKER_RATE_MAX = 30
|
|
42
|
+
/** At most this many motes in one look (one points draw). */
|
|
43
|
+
const LOOK_LIGHT_MOTES_MAX = 2048
|
|
44
|
+
const MOTE_GAIN_MAX = 8
|
|
45
|
+
const MOTE_SIZE_MIN = 0.005
|
|
46
|
+
const MOTE_SIZE_MAX = 1
|
|
47
|
+
const AXIS_X = 0
|
|
48
|
+
const AXIS_Y = 1
|
|
49
|
+
const AXIS_Z = 2
|
|
50
|
+
|
|
51
|
+
/** The sun's shadow look. */
|
|
52
|
+
interface LookShadow {
|
|
53
|
+
intensity: number
|
|
54
|
+
radius: number
|
|
55
|
+
normalBias: number
|
|
56
|
+
}
|
|
57
|
+
/** A lamp's glow: an additive halo `size` metres across at `opacity`. */
|
|
58
|
+
interface LookLampHalo {
|
|
59
|
+
size: number
|
|
60
|
+
opacity: number
|
|
61
|
+
}
|
|
62
|
+
/** A lamp's flicker: `amount` (0 to 1) of its intensity, at about `rate` hertz. */
|
|
63
|
+
interface LookLampFlicker {
|
|
64
|
+
rate: number
|
|
65
|
+
amount: number
|
|
66
|
+
}
|
|
67
|
+
/** Glowing motes drifting in the box `min`..`max`. */
|
|
68
|
+
interface LookMotes {
|
|
69
|
+
count: number
|
|
70
|
+
min: Point
|
|
71
|
+
max: Point
|
|
72
|
+
colour: Rgb
|
|
73
|
+
gain: number
|
|
74
|
+
size: number
|
|
75
|
+
}
|
|
76
|
+
/** `look.grade.vignette`: the frame's dark edge. */
|
|
77
|
+
interface LookVignette {
|
|
78
|
+
offset: number
|
|
79
|
+
darkness: number
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const real = pipe(number(), finite())
|
|
83
|
+
const range = (low: number, high: number): GenericSchema<number, number> =>
|
|
84
|
+
pipe(real, minValue(low), maxValue(high))
|
|
85
|
+
const unit = range(NONE, FULL)
|
|
86
|
+
const colour: GenericSchema<Rgb, Rgb> = tuple([unit, unit, unit])
|
|
87
|
+
const point: GenericSchema<Point, Point> = tuple([real, real, real])
|
|
88
|
+
const moteCount = pipe(
|
|
89
|
+
real,
|
|
90
|
+
integer(),
|
|
91
|
+
minValue(FULL),
|
|
92
|
+
maxValue(LOOK_LIGHT_MOTES_MAX),
|
|
93
|
+
)
|
|
94
|
+
|
|
95
|
+
const LookShadowSchema: GenericSchema<LookShadow, LookShadow> = strictObject({
|
|
96
|
+
intensity: unit,
|
|
97
|
+
radius: range(NONE, SHADOW_RADIUS_MAX),
|
|
98
|
+
normalBias: range(NONE, SHADOW_NORMAL_BIAS_MAX),
|
|
99
|
+
})
|
|
100
|
+
const LookLampHaloSchema: GenericSchema<LookLampHalo, LookLampHalo> =
|
|
101
|
+
strictObject({ size: range(HALO_SIZE_MIN, HALO_SIZE_MAX), opacity: unit })
|
|
102
|
+
const LookLampFlickerSchema: GenericSchema<LookLampFlicker, LookLampFlicker> =
|
|
103
|
+
strictObject({ rate: range(NONE, FLICKER_RATE_MAX), amount: unit })
|
|
104
|
+
const lampDecay: ExactOptionalSchema<
|
|
105
|
+
GenericSchema<number, number>,
|
|
106
|
+
undefined
|
|
107
|
+
> = exactOptional(range(NONE, LAMP_DECAY_MAX))
|
|
108
|
+
const lampHalo: ExactOptionalSchema<
|
|
109
|
+
GenericSchema<LookLampHalo, LookLampHalo>,
|
|
110
|
+
undefined
|
|
111
|
+
> = exactOptional(LookLampHaloSchema)
|
|
112
|
+
const lampFlicker: ExactOptionalSchema<
|
|
113
|
+
GenericSchema<LookLampFlicker, LookLampFlicker>,
|
|
114
|
+
undefined
|
|
115
|
+
> = exactOptional(LookLampFlickerSchema)
|
|
116
|
+
|
|
117
|
+
/** A box's corners, read only. */
|
|
118
|
+
interface MotesBox {
|
|
119
|
+
readonly min: readonly [number, number, number]
|
|
120
|
+
readonly max: readonly [number, number, number]
|
|
121
|
+
}
|
|
122
|
+
function ordered(row: MotesBox): boolean {
|
|
123
|
+
return (
|
|
124
|
+
row.min[AXIS_X] <= row.max[AXIS_X] &&
|
|
125
|
+
row.min[AXIS_Y] <= row.max[AXIS_Y] &&
|
|
126
|
+
row.min[AXIS_Z] <= row.max[AXIS_Z]
|
|
127
|
+
)
|
|
128
|
+
}
|
|
129
|
+
const motesRow = strictObject({
|
|
130
|
+
count: moteCount,
|
|
131
|
+
min: point,
|
|
132
|
+
max: point,
|
|
133
|
+
colour,
|
|
134
|
+
gain: range(NONE, MOTE_GAIN_MAX),
|
|
135
|
+
size: range(MOTE_SIZE_MIN, MOTE_SIZE_MAX),
|
|
136
|
+
})
|
|
137
|
+
const LookMotesSchema: GenericSchema<LookMotes, LookMotes> = pipe(
|
|
138
|
+
motesRow,
|
|
139
|
+
check<LookMotes, string>(ordered, 'Motes box min must not exceed max'),
|
|
140
|
+
)
|
|
141
|
+
const LookVignetteSchema: GenericSchema<LookVignette, LookVignette> =
|
|
142
|
+
strictObject({ offset: unit, darkness: unit })
|
|
143
|
+
|
|
144
|
+
export {
|
|
145
|
+
LOOK_LIGHT_MOTES_MAX,
|
|
146
|
+
LookLampFlickerSchema,
|
|
147
|
+
LookLampHaloSchema,
|
|
148
|
+
LookMotesSchema,
|
|
149
|
+
LookShadowSchema,
|
|
150
|
+
LookVignetteSchema,
|
|
151
|
+
lampDecay,
|
|
152
|
+
lampFlicker,
|
|
153
|
+
lampHalo,
|
|
154
|
+
}
|
|
155
|
+
export type {
|
|
156
|
+
LookLampFlicker,
|
|
157
|
+
LookLampHalo,
|
|
158
|
+
LookMotes,
|
|
159
|
+
LookShadow,
|
|
160
|
+
LookVignette,
|
|
161
|
+
}
|
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
* linear and may exceed 1. Texture references are opaque strings (a shardfile file hash, `commons:<hash>`, or an asset
|
|
16
16
|
* path during the transition) resolved by the caller; textures follow glTF's UV convention (no vertical flip).
|
|
17
17
|
*/
|
|
18
|
+
import { detailLayer } from './detail-layer.ts';
|
|
19
|
+
import type { DetailLayer } from './detail-layer.ts';
|
|
18
20
|
import * as v from 'valibot';
|
|
19
21
|
|
|
20
22
|
const unit = v.pipe(v.number(), v.finite(), v.minValue(0), v.maxValue(1));
|
|
@@ -207,7 +209,7 @@ export function measureUv(role: MeasureRole, u: number, up: number, w: number, h
|
|
|
207
209
|
}
|
|
208
210
|
|
|
209
211
|
/** One PBR surface: metal / rough with colour, normal and packed ORM maps (occlusion r, roughness g, metalness b). */
|
|
210
|
-
export const PbrMaterialSchema: v.StrictObjectSchema<{ readonly family: v.GenericSchema<PbrMaterialParamsInput['family'], PbrMaterialParams['family']>; readonly colour: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['colour'], undefined>, PbrMaterialParams['colour']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['colour'], undefined>>>; readonly roughness: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['roughness'], undefined>, PbrMaterialParams['roughness']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['roughness'], undefined>>>; readonly metalness: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['metalness'], undefined>, PbrMaterialParams['metalness']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['metalness'], undefined>>>; readonly maps: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['maps'], undefined>, PbrMaterialParams['maps']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['maps'], undefined>>>; readonly normalScale: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['normalScale'], undefined>, PbrMaterialParams['normalScale']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['normalScale'], undefined>>>; readonly occlusion: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['occlusion'], undefined>, PbrMaterialParams['occlusion']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['occlusion'], undefined>>>; readonly envStrength: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['envStrength'], undefined>, PbrMaterialParams['envStrength']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['envStrength'], undefined>>>; readonly vertexColours: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['vertexColours'], undefined>, PbrMaterialParams['vertexColours']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['vertexColours'], undefined>>>; readonly faceted: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['faceted'], undefined>, PbrMaterialParams['faceted']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['faceted'], undefined>>>; readonly doubleSided: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['doubleSided'], undefined>, PbrMaterialParams['doubleSided']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['doubleSided'], undefined>>>; readonly alphaCutoff: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['alphaCutoff'], undefined>, PbrMaterialParams['alphaCutoff']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['alphaCutoff'], undefined>>>; readonly ground: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['ground'], undefined>, PbrMaterialParams['ground']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['ground'], undefined>>>; readonly measure: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['measure'], undefined>, PbrMaterialParams['measure']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['measure'], undefined>>>; }, undefined> = v.strictObject({
|
|
212
|
+
export const PbrMaterialSchema: v.StrictObjectSchema<{ readonly family: v.GenericSchema<PbrMaterialParamsInput['family'], PbrMaterialParams['family']>; readonly colour: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['colour'], undefined>, PbrMaterialParams['colour']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['colour'], undefined>>>; readonly roughness: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['roughness'], undefined>, PbrMaterialParams['roughness']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['roughness'], undefined>>>; readonly metalness: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['metalness'], undefined>, PbrMaterialParams['metalness']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['metalness'], undefined>>>; readonly maps: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['maps'], undefined>, PbrMaterialParams['maps']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['maps'], undefined>>>; readonly normalScale: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['normalScale'], undefined>, PbrMaterialParams['normalScale']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['normalScale'], undefined>>>; readonly occlusion: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['occlusion'], undefined>, PbrMaterialParams['occlusion']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['occlusion'], undefined>>>; readonly envStrength: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['envStrength'], undefined>, PbrMaterialParams['envStrength']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['envStrength'], undefined>>>; readonly vertexColours: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['vertexColours'], undefined>, PbrMaterialParams['vertexColours']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['vertexColours'], undefined>>>; readonly faceted: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['faceted'], undefined>, PbrMaterialParams['faceted']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['faceted'], undefined>>>; readonly doubleSided: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['doubleSided'], undefined>, PbrMaterialParams['doubleSided']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['doubleSided'], undefined>>>; readonly alphaCutoff: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['alphaCutoff'], undefined>, PbrMaterialParams['alphaCutoff']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['alphaCutoff'], undefined>>>; readonly ground: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['ground'], undefined>, PbrMaterialParams['ground']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['ground'], undefined>>>; readonly measure: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['measure'], undefined>, PbrMaterialParams['measure']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['measure'], undefined>>>; readonly detail: typeof detailLayer; }, undefined> = v.strictObject({
|
|
211
213
|
family: v.literal('pbr'),
|
|
212
214
|
/** sRGB, multiplies the colour map */
|
|
213
215
|
colour: v.optional(srgb, [1, 1, 1]),
|
|
@@ -231,6 +233,8 @@ export const PbrMaterialSchema: v.StrictObjectSchema<{ readonly family: v.Generi
|
|
|
231
233
|
ground: v.optional(v.nullable(GroundLayerSchema), null),
|
|
232
234
|
/** a procedural measure layer (SF56: the dev-map look, always drawn when declared); null = none */
|
|
233
235
|
measure: v.optional(v.nullable(MeasureLayerSchema), null),
|
|
236
|
+
/** M4.11: a procedural detail layer (world-space mottling, grain, bumps and moss); absent = a plain surface */
|
|
237
|
+
detail: detailLayer,
|
|
234
238
|
});
|
|
235
239
|
/** A PBR material entry with every default filled. */
|
|
236
240
|
|
|
@@ -540,9 +544,9 @@ export interface GroundLayerParamsInput { wind?: [number, number] | undefined; w
|
|
|
540
544
|
export interface GroundLayerParams { wind: [number, number]; wavelength: [number, number]; lump: number; depth: [number, number]; relief: [number, number, number]; contrast: { near: number; far: number; window: [number, number]; strength: number; }; fade: [number, number]; slip: [number, number]; flat: [number, number]; patches: { floor: number; near: number; window: [number, number]; }; grain: { map: (string) | null; mean: number; glintMean: number; strength: number; }; macro: [[number, number, number], [number, number, number]]; albedo: number; streaks: { tint: [number, number, number]; amount: number; }; trail: ({ map: string; rect: [number, number, number, number]; ripples: number; tint: [number, number, number]; amount: number; }) | null; keyShadow: ({ map: string; rect: [number, number, number, number]; edge: [number, number]; floor: number; }) | null; terminator: number; crest: { band: [number, number]; gain: number; }; sheen: number; shade: { tint: [number, number, number]; gain: number; lift: [number, number, number]; amount: number; edge: number; floor: [number, number, number]; }; saturation: { flat: number; facing: number; coolTint: [number, number, number]; keep: number; }; away: { from: [number, number]; amount: number; }; pools: ({ low: [number, number, number]; high: [number, number, number]; split: number; radius: number; gain: number; source?: string; }) | null; }
|
|
541
545
|
export interface MeasureLayerParamsInput { structure?: [number, number, number] | undefined; trim?: [number, number, number] | undefined; floor?: [number, number, number] | undefined; line?: { colour: [number, number, number]; alpha: number; floorAlpha: number; width: number; } | undefined; sub?: { step: number; alpha: number; } | undefined; label?: { colour: [number, number, number]; height: number; } | undefined; lift?: number | undefined; tint?: [number, number, number]; grain?: { amount: [number, number, number]; size: number; }; grid?: [number, number, number]; }
|
|
542
546
|
export interface MeasureLayerParams { structure: [number, number, number]; trim: [number, number, number]; floor: [number, number, number]; line: { colour: [number, number, number]; alpha: number; floorAlpha: number; width: number; }; sub: { step: number; alpha: number; }; label: { colour: [number, number, number]; height: number; }; lift: number; tint?: [number, number, number]; grain?: { amount: [number, number, number]; size: number; }; grid?: [number, number, number]; }
|
|
543
|
-
export interface PbrMaterialParamsInput { family: 'pbr'; colour?: [number, number, number] | undefined; roughness?: number | undefined; metalness?: number | undefined; maps?: { colour: (string) | null; normal: (string) | null; orm: (string) | null; } | undefined; normalScale?: number | undefined; occlusion?: number | undefined; envStrength?: number | undefined; vertexColours?: boolean | undefined; faceted?: boolean | undefined; doubleSided?: boolean | undefined; alphaCutoff?: number | undefined; ground?: (GroundLayerParamsInput) | null | undefined; measure?: (MeasureLayerParamsInput) | null | undefined; }
|
|
547
|
+
export interface PbrMaterialParamsInput { family: 'pbr'; colour?: [number, number, number] | undefined; roughness?: number | undefined; metalness?: number | undefined; maps?: { colour: (string) | null; normal: (string) | null; orm: (string) | null; } | undefined; normalScale?: number | undefined; occlusion?: number | undefined; envStrength?: number | undefined; vertexColours?: boolean | undefined; faceted?: boolean | undefined; doubleSided?: boolean | undefined; alphaCutoff?: number | undefined; ground?: (GroundLayerParamsInput) | null | undefined; measure?: (MeasureLayerParamsInput) | null | undefined; detail?: DetailLayer; }
|
|
544
548
|
// oxlint-disable-next-line typescript/consistent-type-definitions -- Graph admission requires the material alias's implicit dictionary compatibility.
|
|
545
|
-
export type PbrMaterialParams = { family: 'pbr'; colour: [number, number, number]; roughness: number; metalness: number; maps: { colour: (string) | null; normal: (string) | null; orm: (string) | null; }; normalScale: number; occlusion: number; envStrength: number; vertexColours: boolean; faceted: boolean; doubleSided: boolean; alphaCutoff: number; ground: (GroundLayerParams) | null; measure: (MeasureLayerParams) | null; };
|
|
549
|
+
export type PbrMaterialParams = { family: 'pbr'; colour: [number, number, number]; roughness: number; metalness: number; maps: { colour: (string) | null; normal: (string) | null; orm: (string) | null; }; normalScale: number; occlusion: number; envStrength: number; vertexColours: boolean; faceted: boolean; doubleSided: boolean; alphaCutoff: number; ground: (GroundLayerParams) | null; measure: (MeasureLayerParams) | null; detail?: DetailLayer; };
|
|
546
550
|
export interface GradeParamsInput { exposure?: number | undefined; gain?: number | undefined; shoulder?: number | undefined; saturation?: number | undefined; shadowTint?: [number, number, number] | undefined; lightTint?: [number, number, number] | undefined; split?: [number, number] | undefined; contrast?: number | undefined; lookSaturation?: number | undefined; }
|
|
547
551
|
export interface GradeParams { exposure: number; gain: number; shoulder: number; saturation: number; shadowTint: [number, number, number]; lightTint: [number, number, number]; split: [number, number]; contrast: number; lookSaturation: number; }
|
|
548
552
|
export interface PainterlyLookParamsInput { shade?: [number, number, number] | undefined; rim?: [number, number, number] | undefined; warm?: number | undefined; floor?: number | undefined; wet?: number | undefined; wind?: { direction: [number, number]; strength: number; } | undefined; grade?: (GradeParamsInput) | null | undefined; }
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a pool's surface draws (meta TEMPLATES-CLEANROOM M4.1), the optional `surface` of a `water.json` pool:
|
|
3
|
+
*
|
|
4
|
+
* - `reflect`: `planar` mirrors the scene (desktop; phones fall back to `sky`), `sky` reflects the look's sky only.
|
|
5
|
+
* - `tint` (linear): the colour looked straight down into.
|
|
6
|
+
* - `fresnel`: the reflection's share face-on, and the power it rises by toward grazing.
|
|
7
|
+
* - `ripple`: the surface's small waves, `scale` per metre, `amplitude` (screen-space offset), `speed`.
|
|
8
|
+
* - `resolution`: the mirror's texels on a side (absent: the engine's choice for the tier).
|
|
9
|
+
*
|
|
10
|
+
* Absent: the engine's default water, as before. Plain data and checks, no three.js.
|
|
11
|
+
*/
|
|
12
|
+
import {
|
|
13
|
+
exactOptional,
|
|
14
|
+
finite,
|
|
15
|
+
integer,
|
|
16
|
+
maxValue,
|
|
17
|
+
minValue,
|
|
18
|
+
number,
|
|
19
|
+
picklist,
|
|
20
|
+
pipe,
|
|
21
|
+
strictObject,
|
|
22
|
+
tuple,
|
|
23
|
+
} from 'valibot'
|
|
24
|
+
|
|
25
|
+
import type { GenericSchema } from 'valibot'
|
|
26
|
+
|
|
27
|
+
type Rgb = [number, number, number]
|
|
28
|
+
|
|
29
|
+
const NONE = 0
|
|
30
|
+
const FULL = 1
|
|
31
|
+
const FRESNEL_POWER_MIN = 0.5
|
|
32
|
+
const FRESNEL_POWER_MAX = 8
|
|
33
|
+
const RIPPLE_SCALE_MAX = 20
|
|
34
|
+
const RIPPLE_AMPLITUDE_MAX = 0.05
|
|
35
|
+
const RIPPLE_SPEED_MAX = 8
|
|
36
|
+
const RESOLUTION_MIN = 128
|
|
37
|
+
const RESOLUTION_MAX = 2048
|
|
38
|
+
|
|
39
|
+
/** A pool's small waves. */
|
|
40
|
+
interface PoolRipple {
|
|
41
|
+
scale: number
|
|
42
|
+
amplitude: number
|
|
43
|
+
speed: number
|
|
44
|
+
}
|
|
45
|
+
/** A pool's drawn surface. */
|
|
46
|
+
interface PoolSurface {
|
|
47
|
+
reflect: 'planar' | 'sky'
|
|
48
|
+
tint: Rgb
|
|
49
|
+
fresnel: [number, number]
|
|
50
|
+
ripple: PoolRipple
|
|
51
|
+
resolution?: number
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const real = pipe(number(), finite())
|
|
55
|
+
const range = (low: number, high: number): GenericSchema<number, number> =>
|
|
56
|
+
pipe(real, minValue(low), maxValue(high))
|
|
57
|
+
const unit = range(NONE, FULL)
|
|
58
|
+
const tint: GenericSchema<Rgb, Rgb> = tuple([unit, unit, unit])
|
|
59
|
+
const fresnelPower = range(FRESNEL_POWER_MIN, FRESNEL_POWER_MAX)
|
|
60
|
+
const fresnel: GenericSchema<[number, number], [number, number]> = tuple([
|
|
61
|
+
unit,
|
|
62
|
+
fresnelPower,
|
|
63
|
+
])
|
|
64
|
+
const PoolRippleSchema: GenericSchema<PoolRipple, PoolRipple> = strictObject({
|
|
65
|
+
scale: range(NONE, RIPPLE_SCALE_MAX),
|
|
66
|
+
amplitude: range(NONE, RIPPLE_AMPLITUDE_MAX),
|
|
67
|
+
speed: range(NONE, RIPPLE_SPEED_MAX),
|
|
68
|
+
})
|
|
69
|
+
const texels = pipe(
|
|
70
|
+
real,
|
|
71
|
+
integer(),
|
|
72
|
+
minValue(RESOLUTION_MIN),
|
|
73
|
+
maxValue(RESOLUTION_MAX),
|
|
74
|
+
)
|
|
75
|
+
const PoolSurfaceSchema: GenericSchema<PoolSurface, PoolSurface> = strictObject(
|
|
76
|
+
{
|
|
77
|
+
reflect: picklist(['planar', 'sky']),
|
|
78
|
+
tint,
|
|
79
|
+
fresnel,
|
|
80
|
+
ripple: PoolRippleSchema,
|
|
81
|
+
resolution: exactOptional(texels),
|
|
82
|
+
},
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
export { PoolRippleSchema, PoolSurfaceSchema }
|
|
86
|
+
export type { PoolRipple, PoolSurface }
|
|
@@ -6,15 +6,17 @@ import { ForagerContinuation } from './ambientLife.ts';
|
|
|
6
6
|
const finite = v.pipe(v.number(), v.finite());
|
|
7
7
|
const key = v.pipe(v.string(), v.minLength(1), v.maxLength(128));
|
|
8
8
|
const point = v.strictObject({ x: finite, z: finite });
|
|
9
|
-
/** G1004/G872
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
|
|
13
|
-
trees:v.pipe(v.array(v.tuple([finite,finite,v.pipe(finite,v.minValue(0))])),v.
|
|
14
|
-
tops:v.pipe(v.array(finite),v.
|
|
9
|
+
/** The habitat's canopy (one top height per tree) and at most six ledges. G1004/G872 pinned the canopy at exactly 155
|
|
10
|
+
* rows, Nalati's frozen capture; its page now plants 146 (SERVER-PARITY SS10b), so the count follows the shard's own
|
|
11
|
+
* forest: any number up to 4096, one top per tree. */
|
|
12
|
+
const HabitatRows=v.strictObject({
|
|
13
|
+
trees:v.pipe(v.array(v.tuple([finite,finite,v.pipe(finite,v.minValue(0))])),v.maxLength(4096)),
|
|
14
|
+
tops:v.pipe(v.array(finite),v.maxLength(4096)),
|
|
15
15
|
ledges:v.pipe(v.array(v.strictObject({x:finite,y:finite,z:finite,r:v.pipe(finite,v.minValue(0))})),v.maxLength(6)),
|
|
16
16
|
marmots:ForagerContinuation,
|
|
17
17
|
});
|
|
18
|
+
const oneTopPerTree=(rows:{readonly trees:readonly unknown[];readonly tops:readonly unknown[]}):boolean=>rows.tops.length===rows.trees.length;
|
|
19
|
+
export const PopulationHabitatSchema:v.GenericSchema<PopulationHabitatRows,PopulationHabitatRows>=v.pipe(HabitatRows,v.check<PopulationHabitatRows,string>(oneTopPerTree,'Habitat needs one canopy top per tree'));
|
|
18
20
|
export interface PopulationHabitatRows {
|
|
19
21
|
trees:[number,number,number][];tops:number[];ledges:{x:number;y:number;z:number;r:number}[];
|
|
20
22
|
marmots:v.InferOutput<typeof ForagerContinuation>;
|
|
@@ -54,7 +54,9 @@ import { skinLookRules } from './skinAssets.ts';
|
|
|
54
54
|
import { MaterialsSchema, FamilyLooksSchema, MaterialCurvesSchema, TextureSamplersSchema, materialExists, materialTextureRefs, materialGraphRules, materialCurveRules, textureSamplerRules } from './materials.ts';
|
|
55
55
|
import { PostStackSchema, postStackRules } from './postStack.ts';
|
|
56
56
|
import { LookBloomSchema, LookLightSchema, LookToneSchema } from './look-light.ts';
|
|
57
|
+
import { LookVignetteSchema } from './look-render.ts';
|
|
57
58
|
import type { LookBloom, LookBloomInput, LookLight, LookLightInput, LookTone } from './look-light.ts';
|
|
59
|
+
import type { LookVignette } from './look-render.ts';
|
|
58
60
|
|
|
59
61
|
const channel = v.pipe(finite, v.minValue(0), v.maxValue(1));
|
|
60
62
|
const colour = v.tuple([channel, channel, channel]);
|
|
@@ -62,7 +64,7 @@ const unsigned = v.pipe(finite, v.minValue(0));
|
|
|
62
64
|
const key: v.GenericSchema<DayKeyRowsInput, DayKeyRows> = v.strictObject({ time: channel, sky: v.strictObject({ zenith: colour, horizon: colour }), fog: v.strictObject({ colour, density: unsigned, near: v.optional(unsigned), far: v.optional(unsigned) }), sun: v.strictObject({ colour, intensity: unsigned }), ambient: v.strictObject({ sky: colour, ground: colour, intensity: unsigned }) });
|
|
63
65
|
const day: v.GenericSchema<DayRowsInput, DayRows> = v.strictObject({ minutes: v.pipe(finite, v.minValue(1), v.maxValue(1440)), start: channel, maxElevation: v.pipe(finite, v.minValue(0), v.maxValue(90)), azimuth: v.pipe(finite, v.minValue(-180), v.maxValue(180)) });
|
|
64
66
|
const lookBloom = v.exactOptional(LookBloomSchema);
|
|
65
|
-
const lookGrade = v.strictObject({ exposure: finite, saturation: v.pipe(finite, v.minValue(0)), contrast: v.pipe(finite, v.minValue(0)), lut: v.nullable(ref), bloom: lookBloom, tone: v.exactOptional(LookToneSchema) });
|
|
67
|
+
const lookGrade = v.strictObject({ exposure: finite, saturation: v.pipe(finite, v.minValue(0)), contrast: v.pipe(finite, v.minValue(0)), lut: v.nullable(ref), bloom: lookBloom, tone: v.exactOptional(LookToneSchema), vignette: v.exactOptional(LookVignetteSchema) });
|
|
66
68
|
/** A colour LUT file's exact wire size: 33³ RGBA8 (the engine's render/lut format). */
|
|
67
69
|
export const LOOK_LUT_BYTES: number = 33 ** 3 * 4;
|
|
68
70
|
const rawSchema: v.GenericSchema<ShardfileRowsInput, ShardfileRows> & { readonly entries: { readonly [Key in keyof ShardfileRows]-?: v.GenericSchema<ShardfileRowsInput[Key], ShardfileRows[Key]> } } = v.strictObject({
|
|
@@ -184,7 +186,7 @@ export interface Shardfile {
|
|
|
184
186
|
samplers?: v.InferOutput<typeof TextureSamplersSchema>;
|
|
185
187
|
post?: v.InferOutput<typeof PostStackSchema>;
|
|
186
188
|
light?: LookLight;
|
|
187
|
-
grade: { exposure: number; saturation: number; contrast: number; lut: string | null; bloom?: LookBloom; tone?: LookTone };
|
|
189
|
+
grade: { exposure: number; saturation: number; contrast: number; lut: string | null; bloom?: LookBloom; tone?: LookTone; vignette?: LookVignette };
|
|
188
190
|
clock: 'engine';
|
|
189
191
|
day?: v.InferOutput<typeof day> | undefined;
|
|
190
192
|
dayOverride: number | null;
|
|
@@ -398,6 +400,7 @@ interface ShardfileRowsInputFields {
|
|
|
398
400
|
lut: (v.InferInput<typeof ref>) | null;
|
|
399
401
|
bloom?: LookBloomInput;
|
|
400
402
|
tone?: LookTone;
|
|
403
|
+
vignette?: LookVignette;
|
|
401
404
|
};
|
|
402
405
|
clock: 'engine';
|
|
403
406
|
day?: DayRowsInput | undefined;
|
|
@@ -473,6 +476,7 @@ interface ShardfileRowsFields {
|
|
|
473
476
|
lut: (v.InferOutput<typeof ref>) | null;
|
|
474
477
|
bloom?: LookBloom;
|
|
475
478
|
tone?: LookTone;
|
|
479
|
+
vignette?: LookVignette;
|
|
476
480
|
};
|
|
477
481
|
clock: 'engine';
|
|
478
482
|
day?: DayRows | undefined;
|
package/src/format/water.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
|
+
import { PoolSurfaceSchema } from './pool-surface.ts';
|
|
3
|
+
import type { PoolSurface } from './pool-surface.ts';
|
|
2
4
|
|
|
3
5
|
const coord = v.pipe(v.number(), v.finite(), v.minValue(-250), v.maxValue(250));
|
|
4
6
|
export const WaterBodyIdSchema: v.GenericSchema<WaterBodyIdInput, WaterBodyId> = v.pipe(v.string(), v.regex(/^[a-z][a-z0-9.-]*$/u), v.maxLength(128));
|
|
@@ -30,8 +32,9 @@ const dryEntries = v.optional(v.pipe(v.array(v.picklist(['north', 'east', 'south
|
|
|
30
32
|
export const StreamWaterSchema: v.SchemaWithPipe<readonly [v.StrictObjectSchema<{ readonly id: v.GenericSchema<StreamWaterRowsInput['id'], StreamWaterRows['id']>; readonly kind: v.GenericSchema<StreamWaterRowsInput['kind'], StreamWaterRows['kind']>; readonly width: v.GenericSchema<StreamWaterRowsInput['width'], StreamWaterRows['width']>; readonly points: v.GenericSchema<StreamWaterRowsInput['points'], StreamWaterRows['points']>; readonly levels: v.OptionalSchema<v.GenericSchema<Exclude<StreamWaterRowsInput['levels'], undefined>, Exclude<StreamWaterRows['levels'], undefined>>, undefined>; readonly dryEntries: v.OptionalSchema<v.GenericSchema<Exclude<StreamWaterRowsInput['dryEntries'], undefined>, Exclude<StreamWaterRows['dryEntries'], undefined>>, undefined>; }, undefined>, v.CheckAction<{ [K in keyof StreamWaterRows]: StreamWaterRows[K] }, 'stream fits cell, has nonzero segments and declares its live levels'>]> = v.pipe(v.strictObject({ id, kind: v.literal('stream'), width: v.pipe(coord, v.minValue(0.01), v.maxValue(100)), points: v.pipe(v.array(streamPoint), v.minLength(2), v.maxLength(128)), levels, dryEntries }), v.check((s) => s.points.every((p, i) => {
|
|
31
33
|
const prev = s.points[i - 1]; return (p.under === undefined || s.levels?.[p.under] !== undefined) && Math.abs(p.x) + s.width / 2 <= 250 && Math.abs(p.z) + s.width / 2 <= 250 && (prev === undefined || p.x !== prev.x || p.z !== prev.z);
|
|
32
34
|
}), 'stream fits cell, has nonzero segments and declares its live levels'));
|
|
35
|
+
const poolSurface = v.exactOptional(PoolSurfaceSchema);
|
|
33
36
|
export const WaterBodySchema: v.GenericSchema<WaterBodyRowsInput, WaterBodyRows> = v.variant('kind', [
|
|
34
|
-
v.strictObject({ id, kind: v.literal('pool'), level: coord, shape: v.variant('kind', [circle, polygon]), dryEntries }),
|
|
37
|
+
v.strictObject({ id, kind: v.literal('pool'), level: coord, shape: v.variant('kind', [circle, polygon]), dryEntries, surface: poolSurface }),
|
|
35
38
|
v.strictObject({ id: v.literal('sea'), kind: v.literal('sea'), level: coord, waves: v.boolean(), dryEntries }),
|
|
36
39
|
StreamWaterSchema,
|
|
37
40
|
]);
|
|
@@ -124,6 +127,7 @@ export type WaterBodyRowsInput = ({
|
|
|
124
127
|
])[];
|
|
125
128
|
});
|
|
126
129
|
dryEntries?: ('north' | 'east' | 'south' | 'west')[] | undefined;
|
|
130
|
+
surface?: PoolSurface;
|
|
127
131
|
}) | ({
|
|
128
132
|
id: 'sea';
|
|
129
133
|
kind: 'sea';
|
|
@@ -148,6 +152,7 @@ export type WaterBodyRows = ({
|
|
|
148
152
|
])[];
|
|
149
153
|
});
|
|
150
154
|
dryEntries?: ('north' | 'east' | 'south' | 'west')[] | undefined;
|
|
155
|
+
surface?: PoolSurface;
|
|
151
156
|
}) | ({
|
|
152
157
|
id: 'sea';
|
|
153
158
|
kind: 'sea';
|