@wildshard/shard-format 0.49.1 → 0.51.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wildshard/shard-format",
3
- "version": "0.49.1",
3
+ "version": "0.51.0",
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": {
@@ -127,6 +127,7 @@
127
127
  "./pbr-fur": "./src/format/pbr-fur.ts",
128
128
  "./fur-strands": "./src/format/fur-strands.ts",
129
129
  "./scene-render": "./src/format/scene-render.ts",
130
+ "./look-level": "./src/format/look-level.ts",
130
131
  "./look-sky": "./src/format/look-sky.ts",
131
132
  "./directorDocument": "./src/format/directorDocument.ts",
132
133
  "./directorStages": "./src/format/directorStages.ts",
@@ -446,7 +447,8 @@
446
447
  "./interact-table.golden.json": "./src/format/interact-table.golden.json",
447
448
  "./itemCatalogue": "./src/format/item-catalogue.ts",
448
449
  "./item-catalogue.golden.json": "./src/format/item-catalogue.golden.json",
449
- "./baked-terrain.golden.json": "./src/format/baked-terrain.golden.json"
450
+ "./baked-terrain.golden.json": "./src/format/baked-terrain.golden.json",
451
+ "./rigLooks": "./src/format/rig-looks.ts"
450
452
  },
451
453
  "engines": {
452
454
  "node": ">=24.18.0"
@@ -2,17 +2,19 @@ import { hasDeclaredClientPage } from './runtimeBinds.ts';
2
2
  import type { Shardfile } from './shardSchema.ts';
3
3
  import { parseClientPlan } from './clientPlan.ts';
4
4
  import { parseNativeRuntimePlan, nativeRuntimeActorIds } from './nativeRuntimePlan.ts';
5
+ import { pageDrawsDeclaredLooks, rigLookRules } from './rig-looks.ts';
5
6
 
6
7
  /** Cross-section ownership replaces the former runtime-only requirement. This
7
8
  * runs on author output and checked network/native products before allocation. */
8
9
  export function clientOwnershipRules(source: Shardfile, sections: ReadonlyMap<string, unknown>): readonly string[] {
9
- const raw = sections.get('client/plan');
10
+ const raw = sections.get('client/plan'), rigs = rigLookRules(source.rows.looks, sections);
10
11
  const features = raw === undefined ? [] : parseClientPlan(raw).features;
11
12
  const page = hasDeclaredClientPage(source), native = features.some(row => row.kind === 'population.homes');
12
- if (!page && !native) return [];
13
- const errors: string[] = [];
13
+ if (!page && !native) return rigs;
14
+ // OF19d1: a page drawing its declared bodies from their looks needs no species program
15
+ const errors: string[] = [...rigs], program = !pageDrawsDeclaredLooks(source, sections.get('sim/runtime-plan'), features);
14
16
  if (!page || source.runtime !== null) errors.push('Native client features require their typed data page owner');
15
- for (const kind of ['world.scenes', 'motion.channels', 'species.program', 'held.melee', 'quest.page', 'population.homes'] as const)
17
+ for (const kind of ['world.scenes', 'motion.channels', ...program ? ['species.program'] as const : [], 'held.melee', 'quest.page', 'population.homes'] as const)
16
18
  if (!features.some(row => row.kind === kind)) errors.push(`Data page requires ${kind}`);
17
19
  const quest = features.find(row => row.kind === 'quest.page'), held = features.find(row => row.kind === 'held.melee');
18
20
  const declared = source.questHost?.page;
@@ -24,7 +26,7 @@ export function clientOwnershipRules(source: Shardfile, sections: ReadonlyMap<st
24
26
  // ONE-FORMAT OF19b0/OF19c0: declared spawns, their species and encounters run beside the plan's keeper (the engine
25
27
  // refuses a body both own); declared crowds do not
26
28
  if (source.crowds.length > 0) errors.push('Data page native roster cannot also install declared crowds');
27
- for (const name of ['world/scenes', 'world/targets', 'actors/species-programs', 'sim/runtime-plan', 'sim/scripts', 'look/painted'])
29
+ for (const name of ['world/scenes', 'world/targets', ...program ? ['actors/species-programs'] : [], 'sim/runtime-plan', 'sim/scripts', 'look/painted'])
28
30
  if (!sections.has(name)) errors.push(`Data page requires ${name}`);
29
31
  const channels = new Set(source.clientChannels?.map(row => row.id));
30
32
  for (const feature of features) if (feature.kind === 'motion.channels') {
@@ -0,0 +1,164 @@
1
+ /**
2
+ * `look.level` (ONE-FORMAT OF9b2, J365 (7)): the level's sky rig, atmosphere, engine grade and painted horizon, in the
3
+ * look section beside the rest of the look. OF7 gave `look.light.heightFog` and `look.grade.bloom`; these are the words
4
+ * it left the manifest's: the sun's colour, intensity and place, the hemisphere, the environment and background
5
+ * intensity, the sun's tints on fog, cloud and shafts, the grade's saturation, brightness, contrast, split tones, lift,
6
+ * gain and gamma, and the horizon rings. Each keeps the shape and units it had in the manifest (the same schemas,
7
+ * `ManifestMetadataSchema.entries`), so a value moves byte for byte and a shard looks the same.
8
+ *
9
+ * A product built since OF9b2 carries them here and its `ui/level` manifest has no `sky`, `atmosphere`, `grade` or
10
+ * `horizon`; an older product carries them in its manifest. `levelLook` reads the look first and lifts an older
11
+ * manifest's at the door; `liftLevelLook` moves them into `look.level` (the look's own win when both are present).
12
+ *
13
+ * Plain data and checks, no three.js.
14
+ */
15
+ import { exactOptional, strictObject } from 'valibot'
16
+
17
+ import { ManifestMetadataSchema } from './minimap.ts'
18
+
19
+ import type { ManifestMetadata } from './minimap.ts'
20
+ import type { GenericSchema } from 'valibot'
21
+
22
+ /** The sky rig: sun, hemisphere, environment and background intensity, the sun's tints, painted dome, planet, HDRI. */
23
+ type LookLevelSky = NonNullable<ManifestMetadata['sky']>
24
+ /** Distance and height fog and the volumetric light. */
25
+ type LookLevelAtmosphere = NonNullable<ManifestMetadata['atmosphere']>
26
+ /** The engine grade. */
27
+ type LookLevelGrade = NonNullable<ManifestMetadata['grade']>
28
+ /** A painted horizon of rings. */
29
+ type LookLevelHorizon = NonNullable<ManifestMetadata['horizon']>
30
+ /** `look.level`: the sky rig, atmosphere and grade (all three), and a horizon when the level paints one. */
31
+ interface LookLevel {
32
+ sky: LookLevelSky
33
+ atmosphere: LookLevelAtmosphere
34
+ grade: LookLevelGrade
35
+ horizon?: LookLevelHorizon
36
+ }
37
+ type LookLevelInput = LookLevel
38
+ /** The four level fields a manifest carried before OF9b2. */
39
+ type LevelField = 'sky' | 'atmosphere' | 'grade' | 'horizon'
40
+ /** A manifest as the level look reads it: any of the four fields, or none. */
41
+ type LevelManifest = Readonly<Partial<Pick<ManifestMetadata, LevelField>>>
42
+ /** What the level look is read from: a look with an optional level, and an optional manifest. */
43
+ interface LevelLookSource {
44
+ readonly look: { readonly level?: LookLevel }
45
+ readonly manifest?: LevelManifest
46
+ }
47
+
48
+ const LEVEL_FIELDS: readonly LevelField[] = [
49
+ 'sky',
50
+ 'atmosphere',
51
+ 'grade',
52
+ 'horizon',
53
+ ]
54
+ const { entries } = ManifestMetadataSchema
55
+
56
+ /** `look.level`'s schema: the manifest's own sky, atmosphere, grade and horizon schemas. */
57
+ const LookLevelSchema: GenericSchema<LookLevelInput, LookLevel> = strictObject({
58
+ sky: entries.sky.wrapped,
59
+ atmosphere: entries.atmosphere.wrapped,
60
+ grade: entries.grade.wrapped,
61
+ horizon: exactOptional(entries.horizon.wrapped),
62
+ })
63
+
64
+ /** Whether a manifest still carries any of the level look's fields (a product built before OF9b2). */
65
+ // oxlint-disable-next-line typescript/prefer-readonly-parameter-types -- plain JSON rows the caller owns; nothing here writes them
66
+ function manifestCarriesLevel(manifest: LevelManifest): boolean {
67
+ return LEVEL_FIELDS.some((field: LevelField): boolean =>
68
+ Object.hasOwn(manifest, field),
69
+ )
70
+ }
71
+
72
+ /** The level look a manifest carries, when it carries a whole one (sky, atmosphere and grade). */
73
+ // oxlint-disable-next-line typescript/prefer-readonly-parameter-types -- plain JSON rows the caller owns; nothing here writes them
74
+ function manifestLevel(manifest: LevelManifest): LookLevel | undefined {
75
+ const { sky, atmosphere, grade, horizon } = manifest
76
+ if (sky === undefined || atmosphere === undefined || grade === undefined) {
77
+ return undefined
78
+ }
79
+ return horizon === undefined
80
+ ? { sky, atmosphere, grade }
81
+ : { sky, atmosphere, grade, horizon }
82
+ }
83
+
84
+ /** The level look of a shard: its look's, else (a product built before OF9b2) its manifest's; none for a plain shard. */
85
+ // oxlint-disable-next-line typescript/prefer-readonly-parameter-types -- plain JSON rows the caller owns; nothing here writes them
86
+ function levelLook(source: LevelLookSource): LookLevel | undefined {
87
+ if (source.look.level !== undefined) {
88
+ return source.look.level
89
+ }
90
+ return source.manifest === undefined
91
+ ? undefined
92
+ : manifestLevel(source.manifest)
93
+ }
94
+
95
+ /** A manifest without the four level fields. */
96
+ function withoutLevel<Manifest extends LevelManifest>(
97
+ manifest: Manifest,
98
+ ): Omit<Manifest, LevelField> {
99
+ const {
100
+ sky: _sky,
101
+ atmosphere: _atmosphere,
102
+ grade: _grade,
103
+ horizon: _horizon,
104
+ ...rest
105
+ } = manifest
106
+ return rest
107
+ }
108
+
109
+ /**
110
+ * The door for a product built before OF9b2: its manifest's `sky`, `atmosphere`, `grade` and `horizon` move into
111
+ * `look.level` (unless the look already declares one, which wins) and leave the manifest. A source with neither, or
112
+ * already lifted, comes back as it is (the same object).
113
+ */
114
+ function liftLevelLook<Source extends LevelLookSource>(source: Source): Source {
115
+ const { manifest } = source
116
+ if (manifest === undefined || !manifestCarriesLevel(manifest)) {
117
+ return source
118
+ }
119
+ const level = levelLook(source)
120
+ return {
121
+ ...source,
122
+ manifest: withoutLevel(manifest),
123
+ look: level === undefined ? source.look : { ...source.look, level },
124
+ }
125
+ }
126
+
127
+ /** OF9b2's semantic rule: a shard with a manifest has a whole level look, in `look.level` or the manifest, never both. */
128
+ // oxlint-disable-next-line typescript/prefer-readonly-parameter-types -- plain JSON rows the caller owns; nothing here writes them
129
+ function lookLevelRules(source: LevelLookSource): readonly string[] {
130
+ const { manifest } = source
131
+ if (manifest === undefined) {
132
+ return []
133
+ }
134
+ if (source.look.level !== undefined) {
135
+ return manifestCarriesLevel(manifest)
136
+ ? [
137
+ 'look.level: the level look lives in look.level or the manifest, not both',
138
+ ]
139
+ : []
140
+ }
141
+ return manifestLevel(manifest) === undefined
142
+ ? [
143
+ 'look.level: a level needs its sky, atmosphere and grade (look.level, or a manifest built before OF9b2)',
144
+ ]
145
+ : []
146
+ }
147
+
148
+ export {
149
+ LookLevelSchema,
150
+ levelLook,
151
+ liftLevelLook,
152
+ lookLevelRules,
153
+ manifestCarriesLevel,
154
+ }
155
+ export type {
156
+ LevelLookSource,
157
+ LevelManifest,
158
+ LookLevel,
159
+ LookLevelAtmosphere,
160
+ LookLevelGrade,
161
+ LookLevelHorizon,
162
+ LookLevelInput,
163
+ LookLevelSky,
164
+ }
@@ -50,10 +50,12 @@ import {
50
50
  lampDecay,
51
51
  lampFlicker,
52
52
  lampHalo,
53
+ lampPanel,
53
54
  } from './look-render.ts'
54
55
  import { LookSwingsSchema, swingNumber, swingsDeclared } from './look-swing.ts'
55
56
 
56
57
  import type {
58
+ LampPanel,
57
59
  LookLampFlicker,
58
60
  LookLampHalo,
59
61
  LookMotes,
@@ -64,7 +66,6 @@ import type { GenericSchema } from 'valibot'
64
66
 
65
67
  type Rgb = [number, number, number]
66
68
  type Point = [number, number, number]
67
-
68
69
  /** At most this many light pools in one look (one instanced draw). */
69
70
  const LOOK_LIGHT_POOLS_MAX = 64
70
71
  const NONE = 0
@@ -125,7 +126,7 @@ interface LookLampFollow {
125
126
  bone?: string
126
127
  }
127
128
  /** One lamp: a point light at `at`, `colour` × `intensity` (candela), out to `distance` metres, decay 2, no shadow. */
128
- interface LookLamp {
129
+ interface LookLamp extends LampPanel {
129
130
  at: Point
130
131
  follow?: LookLampFollow
131
132
  colour: Rgb
@@ -181,7 +182,6 @@ const colour: GenericSchema<Rgb, Rgb> = tuple([
181
182
  range(NONE, FULL),
182
183
  ])
183
184
  const point: GenericSchema<Point, Point> = tuple([real, real, real])
184
-
185
185
  const LookAoSchema: GenericSchema<LookAo, LookAo> = strictObject({
186
186
  intensity: range(NONE, AO_INTENSITY_MAX),
187
187
  radius: range(AO_RADIUS_MIN, AO_RADIUS_MAX),
@@ -223,6 +223,7 @@ const LookLampSchema: GenericSchema<LookLamp, LookLamp> = strictObject({
223
223
  halo: lampHalo,
224
224
  flicker: lampFlicker,
225
225
  swing: exactOptional(swingNumber),
226
+ panel: exactOptional(lampPanel),
226
227
  })
227
228
  const LookLampsSchema: GenericSchema<LookLamp[], LookLamp[]> = pipe(
228
229
  array(LookLampSchema),
@@ -18,10 +18,13 @@ import {
18
18
  exactOptional,
19
19
  finite,
20
20
  integer,
21
+ maxLength,
21
22
  maxValue,
23
+ minLength,
22
24
  minValue,
23
25
  number,
24
26
  pipe,
27
+ string,
25
28
  strictObject,
26
29
  tuple,
27
30
  } from 'valibot'
@@ -140,6 +143,18 @@ const LookMotesSchema: GenericSchema<LookMotes, LookMotes> = pipe(
140
143
  )
141
144
  const LookVignetteSchema: GenericSchema<LookVignette, LookVignette> =
142
145
  strictObject({ offset: unit, darkness: unit })
146
+ /** Meta MOSSGATE-ZONE MZ34: a lamp may follow a `props.panels` id (a brazier's fire lights with its flames). */
147
+ interface LampPanel {
148
+ /** The panel it lights with: lit while that panel shows, dark while it is hidden */
149
+ panel?: string
150
+ }
151
+ const LAMP_PANEL_LEAST = 1
152
+ const LAMP_PANEL_MAX = 128
153
+ const lampPanel: GenericSchema<string, string> = pipe(
154
+ string(),
155
+ minLength(LAMP_PANEL_LEAST),
156
+ maxLength(LAMP_PANEL_MAX),
157
+ )
143
158
 
144
159
  export {
145
160
  LOOK_LIGHT_MOTES_MAX,
@@ -151,8 +166,10 @@ export {
151
166
  lampDecay,
152
167
  lampFlicker,
153
168
  lampHalo,
169
+ lampPanel,
154
170
  }
155
171
  export type {
172
+ LampPanel,
156
173
  LookLampFlicker,
157
174
  LookLampHalo,
158
175
  LookMotes,
@@ -86,8 +86,26 @@ function swingsDeclared(light: SwingRefs): boolean {
86
86
  return true
87
87
  }
88
88
 
89
+ /** Every lamp's `panel` names a declared `props.panels` row. */
90
+ function lampPanelErrors(
91
+ lamps: readonly Readonly<{ panel?: string }>[],
92
+ panels: readonly Readonly<{ id: string }>[],
93
+ ): string[] {
94
+ const declared = new Set(panels.map((row): string => row.id))
95
+ const errors: string[] = []
96
+ for (const lamp of lamps) {
97
+ if (lamp.panel !== undefined && !declared.has(lamp.panel)) {
98
+ errors.push(
99
+ `look lamp names panel ${lamp.panel}, which props.panels does not declare`,
100
+ )
101
+ }
102
+ }
103
+ return errors
104
+ }
105
+
89
106
  export {
90
107
  LOOK_SWINGS_MAX,
108
+ lampPanelErrors,
91
109
  LookSwingSchema,
92
110
  LookSwingsSchema,
93
111
  swingNumber,
@@ -191,6 +191,26 @@ const art = v.strictObject({ world: image, models: image, sets: image, practice:
191
191
  const band = v.strictObject({ azimuth: number, spread: number, height: number, rough: number });
192
192
  const ring = v.strictObject({ r: number, base: number, color: rgb, top: rgb, snowLine: number, haze: number,
193
193
  bands: v.pipe(v.array(band), v.maxLength(128)), floor: number });
194
+ /**
195
+ * The level's light, air and colour (ONE-FORMAT OF9b2, J365 (7)): the sky rig (sun, hemisphere, environment and
196
+ * background intensity, the sun's tints on fog and cloud, a painted dome, a planet, an HDRI stem), the atmosphere (fog,
197
+ * volumetric light), the engine grade (saturation, brightness, contrast, bloom, split tones, lift, gain, gamma) and a
198
+ * painted horizon. A product built since OF9b2 carries them in `look.level` (`look-level.ts` reads these schemas off
199
+ * `ManifestMetadataSchema.entries`); an older one in its manifest (`ui/level`), which `liftLevelLook` lifts at the door.
200
+ */
201
+ const LevelSkySchema: v.GenericSchema<Exclude<ManifestMetadata['sky'], undefined>, Exclude<ManifestMetadata['sky'], undefined>> = v.strictObject({ hdri: v.exactOptional(v.union([image, v.pipe(text, v.regex(/^[a-z0-9_-]+$/u))])), sunColor: rgb, sunIntensity: number,
202
+ envIntensity: number, bgIntensity: number, fogSunColor: rgb, cloudSunColor: rgb,
203
+ hemiSky: number, hemiGround: number, hemiIntensity: number,
204
+ sun: v.exactOptional(v.strictObject({ azimuth: number, elevation: number })),
205
+ planet: v.exactOptional(v.strictObject({ azimuth: number, elevation: number, size: number, tilt: number, roll: v.exactOptional(number) })),
206
+ painted: v.exactOptional(v.strictObject({ zenith: rgb, horizon: rgb, ground: rgb, glow: rgb })) });
207
+ const LevelAtmosphereSchema: v.GenericSchema<Exclude<ManifestMetadata['atmosphere'], undefined>, Exclude<ManifestMetadata['atmosphere'], undefined>> = v.strictObject({ edgeHaze: v.exactOptional(v.boolean()), wetSurfaces: v.exactOptional(v.boolean()),
208
+ weather: v.exactOptional(v.boolean()), fogHeight: number, fogHeightFalloff: number,
209
+ fogHeightDensity: number, fogDistDensity: number, volumetricSunColor: rgb,
210
+ volumetric: v.exactOptional(v.strictObject({ height: number, falloff: number, density: number, strength: number })) });
211
+ const LevelGradeSchema: v.GenericSchema<Exclude<ManifestMetadata['grade'], undefined>, Exclude<ManifestMetadata['grade'], undefined>> = v.strictObject({ saturation: number, brightness: number, contrast: number, bloomIntensity: number,
212
+ bloomThreshold: number, shadowTint: rgb, highTint: rgb, lift: rgb, gain: rgb, gamma: number });
213
+ const LevelHorizonSchema: v.GenericSchema<Exclude<ManifestMetadata['horizon'], undefined>, Exclude<ManifestMetadata['horizon'], undefined>> = v.strictObject({ rings: v.pipe(v.array(ring), v.maxLength(32)), cloudSea: v.boolean() });
194
214
  /** JSON metadata shared by discovery and the shardfile schema. Native loaders,
195
215
  * generated inventories and terrain/model owners are explicit typed bindings. */
196
216
  const localModule = v.pipe(text, v.regex(/^\.\/[a-zA-Z0-9_-]+(?:[./][a-zA-Z0-9_-]+)*$/u));
@@ -248,7 +268,7 @@ const strings = v.pipe(v.array(text), v.maxLength(256));
248
268
  const optionalFlag = v.exactOptional(v.boolean())
249
269
  const manifestFightFields = v.strictObject({maxHitDamage: v.exactOptional(number), capExempt: v.exactOptional(strings), capExemptTags: v.exactOptional(IncomingCapTagsSchema), attackers: v.exactOptional(v.union([number, v.literal('unbounded')])), telegraphed: v.exactOptional(v.boolean()),
250
270
  input: v.exactOptional(v.strictObject({bufferMs: number, coyoteMs: number}))});
251
- export const ManifestMetadataSchema: v.StrictObjectSchema<{ readonly bindings: v.GenericSchema<ManifestMetadataInput['bindings'], ManifestMetadata['bindings']>; readonly boot: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['boot'], undefined>, Exclude<ManifestMetadata['boot'], undefined>>, undefined>; readonly gridShardfile: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['gridShardfile'], undefined>, Exclude<ManifestMetadata['gridShardfile'], undefined>>, undefined>; readonly shardfile: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['shardfile'], undefined>, Exclude<ManifestMetadata['shardfile'], undefined>>, undefined>; readonly ground: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['ground'], undefined>, Exclude<ManifestMetadata['ground'], undefined>>, undefined>; readonly groundColour: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['groundColour'], undefined>, Exclude<ManifestMetadata['groundColour'], undefined>>, undefined>; readonly world: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['world'], undefined>, Exclude<ManifestMetadata['world'], undefined>>, undefined>; readonly boundary: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['boundary'], undefined>, Exclude<ManifestMetadata['boundary'], undefined>>, undefined>; readonly cellGround: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['cellGround'], undefined>, Exclude<ManifestMetadata['cellGround'], undefined>>, undefined>; readonly hoverSpeedClass: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['hoverSpeedClass'], undefined>, Exclude<ManifestMetadata['hoverSpeedClass'], undefined>>, undefined>; readonly uses: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['uses'], undefined>, Exclude<ManifestMetadata['uses'], undefined>>, undefined>; readonly loadout: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['loadout'], undefined>, Exclude<ManifestMetadata['loadout'], undefined>>, undefined>; readonly species: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['species'], undefined>, Exclude<ManifestMetadata['species'], undefined>>, undefined>; readonly encounters: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['encounters'], undefined>, Exclude<ManifestMetadata['encounters'], undefined>>, undefined>; readonly fight: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['fight'], undefined>, Exclude<ManifestMetadata['fight'], undefined>>, undefined>; readonly creatures: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['creatures'], undefined>, Exclude<ManifestMetadata['creatures'], undefined>>, undefined>; readonly tiers: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['tiers'], undefined>, Exclude<ManifestMetadata['tiers'], undefined>>, undefined>; readonly loot: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['loot'], undefined>, Exclude<ManifestMetadata['loot'], undefined>>, undefined>; readonly hud: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['hud'], undefined>, Exclude<ManifestMetadata['hud'], undefined>>, undefined>; readonly bag: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['bag'], undefined>, Exclude<ManifestMetadata['bag'], undefined>>, undefined>; readonly regionalSimCost: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['regionalSimCost'], undefined>, Exclude<ManifestMetadata['regionalSimCost'], undefined>>, undefined>; readonly spawns: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['spawns'], undefined>, Exclude<ManifestMetadata['spawns'], undefined>>, undefined>; readonly audio: v.GenericSchema<ManifestMetadataInput['audio'], ManifestMetadata['audio']>; readonly api: v.GenericSchema<ManifestMetadataInput['api'], ManifestMetadata['api']>; readonly slug: v.GenericSchema<ManifestMetadataInput['slug'], ManifestMetadata['slug']>; readonly order: v.GenericSchema<ManifestMetadataInput['order'], ManifestMetadata['order']>; readonly status: v.GenericSchema<ManifestMetadataInput['status'], ManifestMetadata['status']>; readonly shardSelect: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['shardSelect'], undefined>, Exclude<ManifestMetadata['shardSelect'], undefined>>, undefined>; readonly name: v.GenericSchema<ManifestMetadataInput['name'], ManifestMetadata['name']>; readonly label: v.GenericSchema<ManifestMetadataInput['label'], ManifestMetadata['label']>; readonly seed: v.GenericSchema<ManifestMetadataInput['seed'], ManifestMetadata['seed']>; readonly biome: v.GenericSchema<ManifestMetadataInput['biome'], ManifestMetadata['biome']>; readonly blurb: v.GenericSchema<ManifestMetadataInput['blurb'], ManifestMetadata['blurb']>; readonly card: v.GenericSchema<ManifestMetadataInput['card'], ManifestMetadata['card']>; readonly style: v.GenericSchema<ManifestMetadataInput['style'], ManifestMetadata['style']>; readonly kitLook: v.GenericSchema<ManifestMetadataInput['kitLook'], ManifestMetadata['kitLook']>; readonly hands: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['hands'], undefined>, Exclude<ManifestMetadata['hands'], undefined>>, undefined>; readonly camera: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['camera'], undefined>, Exclude<ManifestMetadata['camera'], undefined>>, undefined>; readonly weapon: v.GenericSchema<ManifestMetadataInput['weapon'], ManifestMetadata['weapon']>; readonly treeCount: v.GenericSchema<ManifestMetadataInput['treeCount'], ManifestMetadata['treeCount']>; readonly trees: v.GenericSchema<ManifestMetadataInput['trees'], ManifestMetadata['trees']>; readonly assetGlobs: v.GenericSchema<ManifestMetadataInput['assetGlobs'], ManifestMetadata['assetGlobs']>; readonly spawn: v.GenericSchema<ManifestMetadataInput['spawn'], ManifestMetadata['spawn']>; readonly bounds: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['bounds'], undefined>, Exclude<ManifestMetadata['bounds'], undefined>>, undefined>; readonly sky: v.GenericSchema<ManifestMetadataInput['sky'], ManifestMetadata['sky']>; readonly atmosphere: v.GenericSchema<ManifestMetadataInput['atmosphere'], ManifestMetadata['atmosphere']>; readonly grade: v.GenericSchema<ManifestMetadataInput['grade'], ManifestMetadata['grade']>; readonly horizon: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['horizon'], undefined>, Exclude<ManifestMetadata['horizon'], undefined>>, undefined>; readonly minimap: v.GenericSchema<ManifestMetadataInput['minimap'], ManifestMetadata['minimap']>; readonly pois: v.GenericSchema<ManifestMetadataInput['pois'], ManifestMetadata['pois']>; readonly explore: v.GenericSchema<ManifestMetadataInput['explore'], ManifestMetadata['explore']>; readonly captureProbes: v.ExactOptionalSchema<v.ArraySchema<v.GenericSchema<Exclude<ManifestMetadataInput['captureProbes'], undefined>[number], Exclude<ManifestMetadata['captureProbes'], undefined>[number]>, undefined>, undefined>; readonly next: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['next'], undefined>, Exclude<ManifestMetadata['next'], undefined>>, undefined>; readonly debugOptions: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['debugOptions'], undefined>, Exclude<ManifestMetadata['debugOptions'], undefined>>, undefined>; readonly bodyShadow: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['bodyShadow'], undefined>, Exclude<ManifestMetadata['bodyShadow'], undefined>>, undefined>; readonly ocean: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['ocean'], undefined>, Exclude<ManifestMetadata['ocean'], undefined>>, undefined>; readonly blender: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['blender'], undefined>, Exclude<ManifestMetadata['blender'], undefined>>, undefined>; readonly horizonStrips: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['horizonStrips'], undefined>, Exclude<ManifestMetadata['horizonStrips'], undefined>>, undefined>; readonly assets: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['assets'], undefined>, Exclude<ManifestMetadata['assets'], undefined>>, undefined>; readonly look: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['look'], undefined>, Exclude<ManifestMetadata['look'], undefined>>, undefined>; readonly pondLilyExclusions: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['pondLilyExclusions'], undefined>, Exclude<ManifestMetadata['pondLilyExclusions'], undefined>>, undefined>; readonly faunaTuning: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['faunaTuning'], undefined>, Exclude<ManifestMetadata['faunaTuning'], undefined>>, undefined>; readonly forest: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['forest'], undefined>, Exclude<ManifestMetadata['forest'], undefined>>, undefined>; }, undefined> = v.strictObject({
271
+ export const ManifestMetadataSchema: v.StrictObjectSchema<{ readonly bindings: v.GenericSchema<ManifestMetadataInput['bindings'], ManifestMetadata['bindings']>; readonly boot: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['boot'], undefined>, Exclude<ManifestMetadata['boot'], undefined>>, undefined>; readonly gridShardfile: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['gridShardfile'], undefined>, Exclude<ManifestMetadata['gridShardfile'], undefined>>, undefined>; readonly shardfile: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['shardfile'], undefined>, Exclude<ManifestMetadata['shardfile'], undefined>>, undefined>; readonly ground: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['ground'], undefined>, Exclude<ManifestMetadata['ground'], undefined>>, undefined>; readonly groundColour: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['groundColour'], undefined>, Exclude<ManifestMetadata['groundColour'], undefined>>, undefined>; readonly world: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['world'], undefined>, Exclude<ManifestMetadata['world'], undefined>>, undefined>; readonly boundary: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['boundary'], undefined>, Exclude<ManifestMetadata['boundary'], undefined>>, undefined>; readonly cellGround: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['cellGround'], undefined>, Exclude<ManifestMetadata['cellGround'], undefined>>, undefined>; readonly hoverSpeedClass: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['hoverSpeedClass'], undefined>, Exclude<ManifestMetadata['hoverSpeedClass'], undefined>>, undefined>; readonly uses: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['uses'], undefined>, Exclude<ManifestMetadata['uses'], undefined>>, undefined>; readonly loadout: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['loadout'], undefined>, Exclude<ManifestMetadata['loadout'], undefined>>, undefined>; readonly species: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['species'], undefined>, Exclude<ManifestMetadata['species'], undefined>>, undefined>; readonly encounters: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['encounters'], undefined>, Exclude<ManifestMetadata['encounters'], undefined>>, undefined>; readonly fight: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['fight'], undefined>, Exclude<ManifestMetadata['fight'], undefined>>, undefined>; readonly creatures: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['creatures'], undefined>, Exclude<ManifestMetadata['creatures'], undefined>>, undefined>; readonly tiers: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['tiers'], undefined>, Exclude<ManifestMetadata['tiers'], undefined>>, undefined>; readonly loot: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['loot'], undefined>, Exclude<ManifestMetadata['loot'], undefined>>, undefined>; readonly hud: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['hud'], undefined>, Exclude<ManifestMetadata['hud'], undefined>>, undefined>; readonly bag: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['bag'], undefined>, Exclude<ManifestMetadata['bag'], undefined>>, undefined>; readonly regionalSimCost: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['regionalSimCost'], undefined>, Exclude<ManifestMetadata['regionalSimCost'], undefined>>, undefined>; readonly spawns: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['spawns'], undefined>, Exclude<ManifestMetadata['spawns'], undefined>>, undefined>; readonly audio: v.GenericSchema<ManifestMetadataInput['audio'], ManifestMetadata['audio']>; readonly api: v.GenericSchema<ManifestMetadataInput['api'], ManifestMetadata['api']>; readonly slug: v.GenericSchema<ManifestMetadataInput['slug'], ManifestMetadata['slug']>; readonly order: v.GenericSchema<ManifestMetadataInput['order'], ManifestMetadata['order']>; readonly status: v.GenericSchema<ManifestMetadataInput['status'], ManifestMetadata['status']>; readonly shardSelect: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['shardSelect'], undefined>, Exclude<ManifestMetadata['shardSelect'], undefined>>, undefined>; readonly name: v.GenericSchema<ManifestMetadataInput['name'], ManifestMetadata['name']>; readonly label: v.GenericSchema<ManifestMetadataInput['label'], ManifestMetadata['label']>; readonly seed: v.GenericSchema<ManifestMetadataInput['seed'], ManifestMetadata['seed']>; readonly biome: v.GenericSchema<ManifestMetadataInput['biome'], ManifestMetadata['biome']>; readonly blurb: v.GenericSchema<ManifestMetadataInput['blurb'], ManifestMetadata['blurb']>; readonly card: v.GenericSchema<ManifestMetadataInput['card'], ManifestMetadata['card']>; readonly style: v.GenericSchema<ManifestMetadataInput['style'], ManifestMetadata['style']>; readonly kitLook: v.GenericSchema<ManifestMetadataInput['kitLook'], ManifestMetadata['kitLook']>; readonly hands: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['hands'], undefined>, Exclude<ManifestMetadata['hands'], undefined>>, undefined>; readonly camera: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['camera'], undefined>, Exclude<ManifestMetadata['camera'], undefined>>, undefined>; readonly weapon: v.GenericSchema<ManifestMetadataInput['weapon'], ManifestMetadata['weapon']>; readonly treeCount: v.GenericSchema<ManifestMetadataInput['treeCount'], ManifestMetadata['treeCount']>; readonly trees: v.GenericSchema<ManifestMetadataInput['trees'], ManifestMetadata['trees']>; readonly assetGlobs: v.GenericSchema<ManifestMetadataInput['assetGlobs'], ManifestMetadata['assetGlobs']>; readonly spawn: v.GenericSchema<ManifestMetadataInput['spawn'], ManifestMetadata['spawn']>; readonly bounds: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['bounds'], undefined>, Exclude<ManifestMetadata['bounds'], undefined>>, undefined>; readonly sky: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['sky'], undefined>, Exclude<ManifestMetadata['sky'], undefined>>, undefined>; readonly atmosphere: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['atmosphere'], undefined>, Exclude<ManifestMetadata['atmosphere'], undefined>>, undefined>; readonly grade: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['grade'], undefined>, Exclude<ManifestMetadata['grade'], undefined>>, undefined>; readonly horizon: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['horizon'], undefined>, Exclude<ManifestMetadata['horizon'], undefined>>, undefined>; readonly minimap: v.GenericSchema<ManifestMetadataInput['minimap'], ManifestMetadata['minimap']>; readonly pois: v.GenericSchema<ManifestMetadataInput['pois'], ManifestMetadata['pois']>; readonly explore: v.GenericSchema<ManifestMetadataInput['explore'], ManifestMetadata['explore']>; readonly captureProbes: v.ExactOptionalSchema<v.ArraySchema<v.GenericSchema<Exclude<ManifestMetadataInput['captureProbes'], undefined>[number], Exclude<ManifestMetadata['captureProbes'], undefined>[number]>, undefined>, undefined>; readonly next: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['next'], undefined>, Exclude<ManifestMetadata['next'], undefined>>, undefined>; readonly debugOptions: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['debugOptions'], undefined>, Exclude<ManifestMetadata['debugOptions'], undefined>>, undefined>; readonly bodyShadow: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['bodyShadow'], undefined>, Exclude<ManifestMetadata['bodyShadow'], undefined>>, undefined>; readonly ocean: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['ocean'], undefined>, Exclude<ManifestMetadata['ocean'], undefined>>, undefined>; readonly blender: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['blender'], undefined>, Exclude<ManifestMetadata['blender'], undefined>>, undefined>; readonly horizonStrips: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['horizonStrips'], undefined>, Exclude<ManifestMetadata['horizonStrips'], undefined>>, undefined>; readonly assets: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['assets'], undefined>, Exclude<ManifestMetadata['assets'], undefined>>, undefined>; readonly look: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['look'], undefined>, Exclude<ManifestMetadata['look'], undefined>>, undefined>; readonly pondLilyExclusions: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['pondLilyExclusions'], undefined>, Exclude<ManifestMetadata['pondLilyExclusions'], undefined>>, undefined>; readonly faunaTuning: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['faunaTuning'], undefined>, Exclude<ManifestMetadata['faunaTuning'], undefined>>, undefined>; readonly forest: v.ExactOptionalSchema<v.GenericSchema<Exclude<ManifestMetadataInput['forest'], undefined>, Exclude<ManifestMetadata['forest'], undefined>>, undefined>; }, undefined> = v.strictObject({
252
272
  bindings,
253
273
  boot: v.exactOptional(v.strictObject({barrier: v.exactOptional(v.boolean()), cullBeforeFirstDraw: v.exactOptional(v.boolean()),
254
274
  phone: v.exactOptional(v.strictObject({ deferExtras: v.exactOptional(v.boolean()), fragile: v.exactOptional(v.boolean()), trace: v.exactOptional(v.boolean()) })), viewmodelSets: v.exactOptional(v.pipe(v.array(v.picklist(['walnut', 'brushed-steel', 'leather', 'cord', 'bolt', 'anodised', 'polymer', 'gunmetal'])), v.maxLength(8))), shaders: v.exactOptional(v.strictObject({background: v.boolean()})), audio: v.exactOptional(strings), precache: strings, stagedWorld: v.exactOptional(v.boolean()),
@@ -288,19 +308,10 @@ export const ManifestMetadataSchema: v.StrictObjectSchema<{ readonly bindings: v
288
308
  assetGlobs: v.pipe(v.array(text), v.maxLength(128)),
289
309
  spawn: v.strictObject({ x: number, y: v.exactOptional(number), z: number, yaw: number }),
290
310
  bounds: v.exactOptional(v.strictObject({ x0: number, x1: number, z0: number, z1: number, floor: number })),
291
- sky: v.strictObject({ hdri: v.exactOptional(v.union([image, v.pipe(text, v.regex(/^[a-z0-9_-]+$/u))])), sunColor: rgb, sunIntensity: number,
292
- envIntensity: number, bgIntensity: number, fogSunColor: rgb, cloudSunColor: rgb,
293
- hemiSky: number, hemiGround: number, hemiIntensity: number,
294
- sun: v.exactOptional(v.strictObject({ azimuth: number, elevation: number })),
295
- planet: v.exactOptional(v.strictObject({ azimuth: number, elevation: number, size: number, tilt: number, roll: v.exactOptional(number) })),
296
- painted: v.exactOptional(v.strictObject({ zenith: rgb, horizon: rgb, ground: rgb, glow: rgb })) }),
297
- atmosphere: v.strictObject({ edgeHaze: v.exactOptional(v.boolean()), wetSurfaces: v.exactOptional(v.boolean()),
298
- weather: v.exactOptional(v.boolean()), fogHeight: number, fogHeightFalloff: number,
299
- fogHeightDensity: number, fogDistDensity: number, volumetricSunColor: rgb,
300
- volumetric: v.exactOptional(v.strictObject({ height: number, falloff: number, density: number, strength: number })) }),
301
- grade: v.strictObject({ saturation: number, brightness: number, contrast: number, bloomIntensity: number,
302
- bloomThreshold: number, shadowTint: rgb, highTint: rgb, lift: rgb, gain: rgb, gamma: number }),
303
- horizon: v.exactOptional(v.strictObject({ rings: v.pipe(v.array(ring), v.maxLength(32)), cloudSea: v.boolean() })),
311
+ sky: v.exactOptional(LevelSkySchema),
312
+ atmosphere: v.exactOptional(LevelAtmosphereSchema),
313
+ grade: v.exactOptional(LevelGradeSchema),
314
+ horizon: v.exactOptional(LevelHorizonSchema),
304
315
  minimap: v.strictObject({ image, openWater: v.exactOptional(v.strictObject({level: number, deepDepth: number})), outside: v.exactOptional(text) }),
305
316
  pois: v.pipe(v.array(v.strictObject({ id: text, name: text, x: number, z: number, r: v.exactOptional(number), respawn: optionalFlag })), v.maxLength(256)),
306
317
  explore: v.strictObject({ art, compare: v.exactOptional(v.array(v.strictObject({id: text, label: text, model: v.pipe(v.string(), v.maxLength(512)), target: text, live: image, image}))) }),
@@ -700,7 +711,7 @@ export interface ManifestMetadataFields {
700
711
  z1: number;
701
712
  floor: number;
702
713
  };
703
- sky: {
714
+ sky?: {
704
715
  hdri?: string;
705
716
  sunColor: [
706
717
  number,
@@ -757,7 +768,7 @@ export interface ManifestMetadataFields {
757
768
  ];
758
769
  };
759
770
  };
760
- atmosphere: {
771
+ atmosphere?: {
761
772
  edgeHaze?: boolean;
762
773
  wetSurfaces?: boolean;
763
774
  weather?: boolean;
@@ -777,7 +788,7 @@ export interface ManifestMetadataFields {
777
788
  strength: number;
778
789
  };
779
790
  };
780
- grade: {
791
+ grade?: {
781
792
  saturation: number;
782
793
  brightness: number;
783
794
  contrast: number;
@@ -0,0 +1,186 @@
1
+ /**
2
+ * ONE-FORMAT OF19d1: a creature look drawn from a scene model library's baked rig. A look row whose recipe is
3
+ * `platform.rig` names the `world/scenes` models library (`parameters.library`) whose rigs carry the body, and optionally
4
+ * the rig body (`parameters.body`, else the species' kind). The rig brings its own skeleton, surfaces and clips, so the row
5
+ * names no material and its animation is the rig's own (`platform.rig`, no parameters). This replaces a page's
6
+ * `species.program` feature for drawing declared bodies (Sunscar Dunes' ray, strider and Matriarch).
7
+ */
8
+ import {
9
+ exactOptional,
10
+ maxLength,
11
+ minLength,
12
+ parse,
13
+ pipe,
14
+ safeParse,
15
+ strictObject,
16
+ string,
17
+ } from 'valibot'
18
+
19
+ import { nativeRuntimeActorIds } from './nativeRuntimePlan.ts'
20
+
21
+ import type { GenericSchema } from 'valibot'
22
+
23
+ /** The look recipe, and its animation recipe, for a body drawn from a scene library's rig. */
24
+ const RIG_LOOK_RECIPE = 'platform.rig'
25
+ const ID_MIN = 1
26
+ const ID_MAX = 128
27
+ const NONE = 0
28
+ const rowId = pipe(string(), minLength(ID_MIN), maxLength(ID_MAX))
29
+ /** The look row's parameters: the library, and the rig body when it is not the species' kind. */
30
+ interface RigLookParameters {
31
+ readonly library: string
32
+ readonly body?: string
33
+ }
34
+ const RigLookParametersSchema: GenericSchema<RigLookParameters> = strictObject({
35
+ body: exactOptional(rowId),
36
+ library: rowId,
37
+ })
38
+ /** The fields of a look row these rules read. */
39
+ interface RigLookRow {
40
+ readonly id: string
41
+ readonly species: string
42
+ readonly recipe: string
43
+ readonly material: string | null
44
+ readonly parameters: Readonly<Record<string, unknown>>
45
+ readonly animation: {
46
+ readonly recipe: string
47
+ readonly parameters: Readonly<Record<string, unknown>>
48
+ readonly clipMap?: unknown
49
+ }
50
+ }
51
+ /** The fields of a shard these rules read. */
52
+ interface RigLookShard {
53
+ readonly rows: { readonly looks: readonly RigLookRow[] }
54
+ readonly creatures: {
55
+ readonly spawns: readonly { readonly species: string }[]
56
+ }
57
+ }
58
+
59
+ /** Whether a look plays its rig's own clips: the rig recipe, no parameters and no clip map. */
60
+ function ownClips(row: Readonly<RigLookRow>): boolean {
61
+ const { animation } = row
62
+ return (
63
+ animation.recipe === RIG_LOOK_RECIPE &&
64
+ Object.keys(animation.parameters).length === NONE &&
65
+ animation.clipMap === undefined
66
+ )
67
+ }
68
+
69
+ /** The errors of one `platform.rig` look's own fields (none for another recipe whose animation is not the rig's). */
70
+ function rigLookRowRules(row: Readonly<RigLookRow>): readonly string[] {
71
+ if (row.recipe !== RIG_LOOK_RECIPE) {
72
+ return row.animation.recipe === RIG_LOOK_RECIPE
73
+ ? [`Rig clips without a rig look: ${row.id}`]
74
+ : []
75
+ }
76
+ const errors: string[] = []
77
+ if (!safeParse(RigLookParametersSchema, row.parameters).success) {
78
+ errors.push(
79
+ `Rig look parameters are a library and an optional body: ${row.id}`,
80
+ )
81
+ }
82
+ if (row.material !== null) {
83
+ errors.push(`A rig look draws with its rig's surfaces: ${row.id}`)
84
+ }
85
+ if (!ownClips(row)) {
86
+ errors.push(`A rig look plays its rig's own clips: ${row.id}`)
87
+ }
88
+ return errors
89
+ }
90
+
91
+ /** The parameters of a rig look that passed `rigLookRules`. */
92
+ function rigLookParameters(
93
+ row: Readonly<Pick<RigLookRow, 'parameters'>>,
94
+ ): RigLookParameters {
95
+ return parse(RigLookParametersSchema, row.parameters)
96
+ }
97
+
98
+ /** Whether a value is a plain JSON object. */
99
+ function isObject(value: unknown): value is Readonly<Record<string, unknown>> {
100
+ return typeof value === 'object' && value !== null && !Array.isArray(value)
101
+ }
102
+
103
+ /** The ids of the `models` libraries a `world/scenes` section declares. */
104
+ function modelLibraries(scenes: unknown): ReadonlySet<string> {
105
+ const libraries: unknown = isObject(scenes) ? scenes['libraries'] : undefined
106
+ const rows: readonly unknown[] = Array.isArray(libraries) ? libraries : []
107
+ return new Set(
108
+ rows.flatMap((row: unknown): string[] =>
109
+ isObject(row) && row['kind'] === 'models' && typeof row['id'] === 'string'
110
+ ? [row['id']]
111
+ : [],
112
+ ),
113
+ )
114
+ }
115
+
116
+ /** Every look's rig rules, and cross-section: every rig look names a `models` library of `world/scenes` (the rig body is
117
+ * the library file's, checked where the page loads it). */
118
+ function rigLookRules(
119
+ looks: readonly RigLookRow[],
120
+ sections: ReadonlyMap<string, unknown>,
121
+ ): readonly string[] {
122
+ const rows = looks.flatMap((row: Readonly<RigLookRow>): readonly string[] =>
123
+ rigLookRowRules(row),
124
+ )
125
+ const rigged = looks.filter(
126
+ (row: Readonly<RigLookRow>): boolean => row.recipe === RIG_LOOK_RECIPE,
127
+ )
128
+ if (rigged.length === NONE) {
129
+ return rows
130
+ }
131
+ const models = modelLibraries(sections.get('world/scenes'))
132
+ const libraries = rigged.flatMap((row: Readonly<RigLookRow>): string[] => {
133
+ const { library } = row.parameters
134
+ return typeof library === 'string' && models.has(library)
135
+ ? []
136
+ : [`Rig look ${row.id} names no world/scenes models library`]
137
+ })
138
+ return [...rows, ...libraries]
139
+ }
140
+
141
+ /** OF19d1: a page whose plan keeper stands no body (`keeper` is its actor ids), and whose every declared spawn's species
142
+ * has a look row, draws its creatures as an ordinary upload does, so it needs no `species.program` feature. */
143
+ function declaredLooksDraw(
144
+ shard: Readonly<RigLookShard>,
145
+ keeper: readonly string[],
146
+ ): boolean {
147
+ if (keeper.length > NONE) {
148
+ return false
149
+ }
150
+ const looked = new Set(
151
+ shard.rows.looks.map((row: Readonly<RigLookRow>): string => row.species),
152
+ )
153
+ return shard.creatures.spawns.every(
154
+ (spawn: Readonly<{ species: string }>): boolean =>
155
+ looked.has(spawn.species),
156
+ )
157
+ }
158
+
159
+ /** Whether a data page draws its declared bodies from their looks: it has no `species.program` feature, its runtime plan's
160
+ * keeper (`plan`, the `sim/runtime-plan` section) stands no body, and every declared spawn's species has a look. */
161
+ function pageDrawsDeclaredLooks(
162
+ shard: Readonly<RigLookShard>,
163
+ plan: unknown,
164
+ features: readonly Readonly<{ kind: string }>[],
165
+ ): boolean {
166
+ if (
167
+ plan === undefined ||
168
+ features.some(
169
+ (row: Readonly<{ kind: string }>): boolean =>
170
+ row.kind === 'species.program',
171
+ )
172
+ ) {
173
+ return false
174
+ }
175
+ return declaredLooksDraw(shard, nativeRuntimeActorIds(plan))
176
+ }
177
+
178
+ export {
179
+ RIG_LOOK_RECIPE,
180
+ RigLookParametersSchema,
181
+ declaredLooksDraw,
182
+ pageDrawsDeclaredLooks,
183
+ rigLookParameters,
184
+ rigLookRules,
185
+ }
186
+ export type { RigLookParameters, RigLookRow, RigLookShard }
@@ -45,6 +45,7 @@ import { ItemsSchema, itemRules } from './items.ts';
45
45
  import { TraversalSchema } from './traversal.ts';
46
46
  import { RuntimeSchema } from './runtime.ts';
47
47
  import { ClientScriptsSchema, clientScriptRules } from './clientScripts.ts';
48
+ import { lampPanelErrors } from './look-swing.ts';
48
49
  import { ClientChannelsSchema } from './clientChannels.ts';
49
50
  import { EdgeProfilesSchema } from './edgeProfiles.ts';
50
51
  import { EntrywaysSchema, entrywayRules } from './entryways.ts';
@@ -68,6 +69,8 @@ import { LookBloomSchema, LookLightSchema, LookToneSchema } from './look-light.t
68
69
  import { LookVignetteSchema } from './look-render.ts';
69
70
  import type { LookBloom, LookBloomInput, LookLight, LookLightInput, LookTone } from './look-light.ts';
70
71
  import { LookDetailsSchema, detailLayerRules } from './look-details.ts';
72
+ import { LookLevelSchema, lookLevelRules } from './look-level.ts';
73
+ import type { LookLevel, LookLevelInput } from './look-level.ts';
71
74
  import type { LookDetail } from './look-details.ts';
72
75
  import type { LookVignette } from './look-render.ts';
73
76
 
@@ -89,7 +92,7 @@ const rawSchema: v.GenericSchema<ShardfileRowsInput, ShardfileRows> & { readonly
89
92
  map: v.exactOptional(MapSchema),
90
93
  requires: RequiresSchema,
91
94
  budgets: BudgetsSchema,
92
- look: v.strictObject({ families: names, materials: v.optional(MaterialsSchema, {}), familyLooks: v.optional(FamilyLooksSchema, {}), curves: v.exactOptional(MaterialCurvesSchema), samplers: v.exactOptional(TextureSamplersSchema), post: v.exactOptional(PostStackSchema), sky: v.exactOptional(LookSkySchema), light: v.exactOptional(LookLightSchema), details: v.exactOptional(LookDetailsSchema), grade: lookGrade, clock: v.literal('engine'), day: v.optional(day), dayOverride: v.nullable(channel), keys: v.pipe(v.array(key), v.maxLength(64)) }),
95
+ look: v.strictObject({ families: names, materials: v.optional(MaterialsSchema, {}), familyLooks: v.optional(FamilyLooksSchema, {}), curves: v.exactOptional(MaterialCurvesSchema), samplers: v.exactOptional(TextureSamplersSchema), post: v.exactOptional(PostStackSchema), sky: v.exactOptional(LookSkySchema), light: v.exactOptional(LookLightSchema), level: v.exactOptional(LookLevelSchema), details: v.exactOptional(LookDetailsSchema), grade: lookGrade, clock: v.literal('engine'), day: v.optional(day), dayOverride: v.nullable(channel), keys: v.pipe(v.array(key), v.maxLength(64)) }),
93
96
  sim: SimSchema,
94
97
  state: StateSchema,
95
98
  migrations: v.optional(MigrationsSchema, []),
@@ -200,6 +203,7 @@ export interface Shardfile {
200
203
  post?: v.InferOutput<typeof PostStackSchema>;
201
204
  sky?: LookSky;
202
205
  light?: LookLight;
206
+ level?: LookLevel;
203
207
  details?: LookDetail[];
204
208
  grade: { exposure: number; saturation: number; contrast: number; lut: string | null; bloom?: LookBloom; tone?: LookTone; vignette?: LookVignette };
205
209
  clock: 'engine';
@@ -335,7 +339,7 @@ export function shardfileRules(s: Shardfile, sections?: ReadonlyMap<string, unkn
335
339
  }
336
340
  if (s.runtime !== null && s.modes?.traverse.some(row => row.kind === 'ladder')) errors.push('ladder traversal requires the data-only player owner');
337
341
  errors.push(...skinLookRules(s), ...attachmentFileRules({ species: s.rows.species, files: s.files, library: s.library, materials: s.look.materials }));
338
- errors.push(...clientScriptRules(s));
342
+ errors.push(...lookLevelRules(s), ...clientScriptRules(s), ...lampPanelErrors(s.look.light?.lamps ?? [], s.props?.panels ?? []));
339
343
  if (s.props !== null) {
340
344
  try { validatePropsReferences(s.props, s); } catch { errors.push('declared prop references'); }
341
345
  if (!materialExists(s.look.materials, s.props.family)) errors.push('declared prop material');
@@ -477,6 +481,7 @@ interface ShardfileRowsInputFields {
477
481
  post?: v.InferInput<typeof PostStackSchema>;
478
482
  sky?: LookSkyInput;
479
483
  light?: LookLightInput;
484
+ level?: LookLevelInput;
480
485
  details?: LookDetail[];
481
486
  grade: {
482
487
  exposure: v.InferInput<typeof finite>;
@@ -555,6 +560,7 @@ interface ShardfileRowsFields {
555
560
  post?: v.InferOutput<typeof PostStackSchema>;
556
561
  sky?: LookSky;
557
562
  light?: LookLight;
563
+ level?: LookLevel;
558
564
  details?: LookDetail[];
559
565
  grade: {
560
566
  exposure: v.InferOutput<typeof finite>;