@wildshard/shard-format 0.5.9 → 0.6.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 +3 -1
- package/src/format/creature-layers.ts +262 -0
- package/src/format/creature-skeletons.ts +137 -0
- package/src/format/minimap.ts +5 -1
- package/src/format/rows.ts +36 -8
- package/src/format/skin-file.ts +64 -0
- package/src/format/skin-variants.ts +190 -0
- package/src/format/skinAssets.ts +31 -37
- package/src/format/skins.ts +26 -12
- package/src/format/speciesPrograms.ts +22 -17
- package/src/format/view-draws.ts +15 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wildshard/shard-format",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.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": {
|
|
@@ -94,6 +94,8 @@
|
|
|
94
94
|
"./contracts": "./src/format/contracts.ts",
|
|
95
95
|
"./coverAppearance": "./src/format/coverAppearance.ts",
|
|
96
96
|
"./creatures": "./src/format/creatures.ts",
|
|
97
|
+
"./creatureLayers": "./src/format/creature-layers.ts",
|
|
98
|
+
"./creatureSkeletons": "./src/format/creature-skeletons.ts",
|
|
97
99
|
"./crowdPresentation": "./src/format/crowdPresentation.ts",
|
|
98
100
|
"./crowds": "./src/format/crowds.ts",
|
|
99
101
|
"./cueDirector": "./src/format/cueDirector.ts",
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import {
|
|
2
|
+
array,
|
|
3
|
+
boolean,
|
|
4
|
+
check,
|
|
5
|
+
exactOptional,
|
|
6
|
+
finite,
|
|
7
|
+
maxLength,
|
|
8
|
+
maxEntries,
|
|
9
|
+
maxValue,
|
|
10
|
+
minLength,
|
|
11
|
+
minValue,
|
|
12
|
+
number,
|
|
13
|
+
picklist,
|
|
14
|
+
pipe,
|
|
15
|
+
regex,
|
|
16
|
+
record,
|
|
17
|
+
strictObject,
|
|
18
|
+
string,
|
|
19
|
+
tuple,
|
|
20
|
+
union,
|
|
21
|
+
} from 'valibot'
|
|
22
|
+
|
|
23
|
+
import { HuntTuningSchema } from './speciesPrograms.ts'
|
|
24
|
+
|
|
25
|
+
import type { SpeciesData } from './speciesPrograms.ts'
|
|
26
|
+
import type { GenericSchema } from 'valibot'
|
|
27
|
+
|
|
28
|
+
/** Labels for quest and journal filters; these never choose mechanics. */
|
|
29
|
+
type CreatureType =
|
|
30
|
+
| 'beast'
|
|
31
|
+
| 'humanoid'
|
|
32
|
+
| 'giant'
|
|
33
|
+
| 'dragonkin'
|
|
34
|
+
| 'undead'
|
|
35
|
+
| 'elemental'
|
|
36
|
+
| 'construct'
|
|
37
|
+
| 'insect'
|
|
38
|
+
| 'aquatic'
|
|
39
|
+
| 'critter'
|
|
40
|
+
| 'aberration'
|
|
41
|
+
type CreatureSkeleton = 'quadruped' | 'biped'
|
|
42
|
+
type CreatureSize = 'tiny' | 'small' | 'medium' | 'large' | 'giant'
|
|
43
|
+
type CreatureReaction = 'passive' | 'skittish' | 'neutral' | 'aggressive'
|
|
44
|
+
type CreatureTuningScalar = number | boolean | string
|
|
45
|
+
type CreatureTuningValue =
|
|
46
|
+
| CreatureTuningScalar
|
|
47
|
+
| CreatureTuningScalar[]
|
|
48
|
+
| Record<string, CreatureTuningScalar>
|
|
49
|
+
type CreatureTuning = Record<string, CreatureTuningValue>
|
|
50
|
+
|
|
51
|
+
interface CreatureBody {
|
|
52
|
+
/** Omit for a GLB with its own rig; a kit poser names its contract explicitly. */
|
|
53
|
+
skeleton?: CreatureSkeleton
|
|
54
|
+
size: CreatureSize
|
|
55
|
+
scale: number
|
|
56
|
+
look: string
|
|
57
|
+
}
|
|
58
|
+
/** The spawn supplies home position; these numbers control its return policy. */
|
|
59
|
+
interface CreatureTemperament {
|
|
60
|
+
brain: string
|
|
61
|
+
reaction: CreatureReaction
|
|
62
|
+
leash: number
|
|
63
|
+
assist: number
|
|
64
|
+
home: { speed: number; stop: number }
|
|
65
|
+
pack?: boolean
|
|
66
|
+
territorial?: number
|
|
67
|
+
ambush?: boolean
|
|
68
|
+
flee?: number
|
|
69
|
+
tuning?: NonNullable<SpeciesData['tuning']> | CreatureTuning
|
|
70
|
+
}
|
|
71
|
+
interface CreatureSenses {
|
|
72
|
+
notice: number
|
|
73
|
+
sight?: { range: number; cone: number; graze?: number }
|
|
74
|
+
hearing?: { still: number; crouch: number; walk: number; sprint: number }
|
|
75
|
+
reveal?: number
|
|
76
|
+
}
|
|
77
|
+
/** Ordered strike-row references. A scalar range means zero through that radius. */
|
|
78
|
+
interface CreatureAbility {
|
|
79
|
+
use: string
|
|
80
|
+
range: number | [number, number]
|
|
81
|
+
cooldown: number
|
|
82
|
+
weight: number
|
|
83
|
+
hpBelow?: number
|
|
84
|
+
damage?: number
|
|
85
|
+
speed?: number
|
|
86
|
+
windup?: number
|
|
87
|
+
duration?: number
|
|
88
|
+
}
|
|
89
|
+
interface CreaturePresentation {
|
|
90
|
+
blood: boolean
|
|
91
|
+
sounds: {
|
|
92
|
+
call?: string
|
|
93
|
+
hurt?: string
|
|
94
|
+
callVariants?: string[]
|
|
95
|
+
callEvery?: [number, number]
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/** Additive fields: absence is preserved without injecting a default layer. */
|
|
99
|
+
interface CreatureLayers {
|
|
100
|
+
type?: CreatureType
|
|
101
|
+
body?: CreatureBody
|
|
102
|
+
temperament?: CreatureTemperament
|
|
103
|
+
senses?: CreatureSenses
|
|
104
|
+
abilities?: CreatureAbility[]
|
|
105
|
+
presentation?: CreaturePresentation
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const ZERO = 0
|
|
109
|
+
const ONE = 1
|
|
110
|
+
const MAX_ID = 128
|
|
111
|
+
const MAX_SOUND = 4096
|
|
112
|
+
const MAX_RADIUS = 500
|
|
113
|
+
const MAX_SPEED = 15
|
|
114
|
+
const MAX_TIME = 86_400
|
|
115
|
+
const MAX_AMOUNT = 10_000_000
|
|
116
|
+
const MAX_SCALE = 10
|
|
117
|
+
const MAX_CALLS = 32
|
|
118
|
+
const MAX_TUNING_FIELDS = 64
|
|
119
|
+
|
|
120
|
+
const id = pipe(string(), regex(/^[a-z][a-zA-Z0-9.:-]*$/u), maxLength(MAX_ID))
|
|
121
|
+
const sound = pipe(string(), minLength(ONE), maxLength(MAX_SOUND))
|
|
122
|
+
const scalar = pipe(number(), finite())
|
|
123
|
+
const radius = pipe(scalar, minValue(ZERO), maxValue(MAX_RADIUS))
|
|
124
|
+
const speed = pipe(scalar, minValue(ZERO), maxValue(MAX_SPEED))
|
|
125
|
+
const unit = pipe(scalar, minValue(ZERO), maxValue(ONE))
|
|
126
|
+
const time = pipe(scalar, minValue(ZERO), maxValue(MAX_TIME))
|
|
127
|
+
const amount = pipe(scalar, minValue(ZERO), maxValue(MAX_AMOUNT))
|
|
128
|
+
const orderedRadius = pipe(
|
|
129
|
+
tuple([radius, radius]),
|
|
130
|
+
check<[number, number], 'Ordered creature ability range'>(
|
|
131
|
+
([near, far]: readonly [number, number]): boolean => near <= far,
|
|
132
|
+
'Ordered creature ability range',
|
|
133
|
+
),
|
|
134
|
+
)
|
|
135
|
+
const orderedTime = pipe(
|
|
136
|
+
tuple([time, time]),
|
|
137
|
+
check<[number, number], 'Ordered creature call interval'>(
|
|
138
|
+
([near, far]: readonly [number, number]): boolean => near <= far,
|
|
139
|
+
'Ordered creature call interval',
|
|
140
|
+
),
|
|
141
|
+
)
|
|
142
|
+
const tuningNumber = pipe(scalar, minValue(-MAX_AMOUNT), maxValue(MAX_AMOUNT))
|
|
143
|
+
const tuningScalar = union([tuningNumber, boolean(), sound])
|
|
144
|
+
const tuningList = pipe(array(tuningScalar), maxLength(MAX_CALLS))
|
|
145
|
+
const tuningObject = pipe(
|
|
146
|
+
record(id, tuningScalar),
|
|
147
|
+
maxEntries(MAX_TUNING_FIELDS),
|
|
148
|
+
)
|
|
149
|
+
const tuningValue = union([tuningScalar, tuningList, tuningObject])
|
|
150
|
+
const brainTuning = pipe(record(id, tuningValue), maxEntries(MAX_TUNING_FIELDS))
|
|
151
|
+
const tuning = union([HuntTuningSchema, brainTuning])
|
|
152
|
+
|
|
153
|
+
/** Schemas are separately bounded so their defining declaration stays small. */
|
|
154
|
+
const CreatureTypeSchema: GenericSchema<CreatureType> = picklist(
|
|
155
|
+
[
|
|
156
|
+
'beast',
|
|
157
|
+
'humanoid',
|
|
158
|
+
'giant',
|
|
159
|
+
'dragonkin',
|
|
160
|
+
'undead',
|
|
161
|
+
'elemental',
|
|
162
|
+
'construct',
|
|
163
|
+
'insect',
|
|
164
|
+
'aquatic',
|
|
165
|
+
'critter',
|
|
166
|
+
'aberration',
|
|
167
|
+
],
|
|
168
|
+
'Unknown creature type',
|
|
169
|
+
)
|
|
170
|
+
const CreatureBodySchema: GenericSchema<CreatureBody> = strictObject({
|
|
171
|
+
skeleton: exactOptional(
|
|
172
|
+
picklist(['quadruped', 'biped'], 'Unknown creature skeleton'),
|
|
173
|
+
),
|
|
174
|
+
size: picklist(
|
|
175
|
+
['tiny', 'small', 'medium', 'large', 'giant'],
|
|
176
|
+
'Unknown creature size',
|
|
177
|
+
),
|
|
178
|
+
scale: pipe(scalar, minValue(Number.MIN_VALUE), maxValue(MAX_SCALE)),
|
|
179
|
+
look: id,
|
|
180
|
+
})
|
|
181
|
+
const CreatureTemperamentSchema: GenericSchema<CreatureTemperament> =
|
|
182
|
+
strictObject({
|
|
183
|
+
brain: id,
|
|
184
|
+
reaction: picklist(
|
|
185
|
+
['passive', 'skittish', 'neutral', 'aggressive'],
|
|
186
|
+
'Unknown creature reaction',
|
|
187
|
+
),
|
|
188
|
+
leash: radius,
|
|
189
|
+
assist: radius,
|
|
190
|
+
home: strictObject({ speed, stop: radius }),
|
|
191
|
+
pack: exactOptional(boolean()),
|
|
192
|
+
territorial: exactOptional(radius),
|
|
193
|
+
ambush: exactOptional(boolean()),
|
|
194
|
+
flee: exactOptional(unit),
|
|
195
|
+
tuning: exactOptional(tuning),
|
|
196
|
+
})
|
|
197
|
+
const sight = strictObject({
|
|
198
|
+
range: radius,
|
|
199
|
+
cone: pipe(scalar, minValue(ZERO), maxValue(Math.PI)),
|
|
200
|
+
graze: exactOptional(radius),
|
|
201
|
+
})
|
|
202
|
+
const hearing = strictObject({
|
|
203
|
+
still: radius,
|
|
204
|
+
crouch: radius,
|
|
205
|
+
walk: radius,
|
|
206
|
+
sprint: radius,
|
|
207
|
+
})
|
|
208
|
+
const CreatureSensesSchema: GenericSchema<CreatureSenses> = strictObject(
|
|
209
|
+
{
|
|
210
|
+
notice: radius,
|
|
211
|
+
sight: exactOptional(sight),
|
|
212
|
+
hearing: exactOptional(hearing),
|
|
213
|
+
reveal: exactOptional(radius),
|
|
214
|
+
},
|
|
215
|
+
'Unknown creature sense',
|
|
216
|
+
)
|
|
217
|
+
const CreatureAbilitySchema: GenericSchema<CreatureAbility> = strictObject({
|
|
218
|
+
use: id,
|
|
219
|
+
range: union([radius, orderedRadius]),
|
|
220
|
+
cooldown: time,
|
|
221
|
+
weight: amount,
|
|
222
|
+
hpBelow: exactOptional(unit),
|
|
223
|
+
damage: exactOptional(amount),
|
|
224
|
+
speed: exactOptional(amount),
|
|
225
|
+
windup: exactOptional(time),
|
|
226
|
+
duration: exactOptional(time),
|
|
227
|
+
})
|
|
228
|
+
const callVariants = pipe(array(sound), maxLength(MAX_CALLS))
|
|
229
|
+
const CreaturePresentationSchema: GenericSchema<CreaturePresentation> =
|
|
230
|
+
strictObject({
|
|
231
|
+
blood: boolean(),
|
|
232
|
+
sounds: strictObject({
|
|
233
|
+
call: exactOptional(sound),
|
|
234
|
+
hurt: exactOptional(sound),
|
|
235
|
+
callVariants: exactOptional(callVariants),
|
|
236
|
+
callEvery: exactOptional(orderedTime),
|
|
237
|
+
}),
|
|
238
|
+
})
|
|
239
|
+
|
|
240
|
+
export {
|
|
241
|
+
CreatureTypeSchema,
|
|
242
|
+
CreatureBodySchema,
|
|
243
|
+
CreatureTemperamentSchema,
|
|
244
|
+
CreatureSensesSchema,
|
|
245
|
+
CreatureAbilitySchema,
|
|
246
|
+
CreaturePresentationSchema,
|
|
247
|
+
}
|
|
248
|
+
export type {
|
|
249
|
+
CreatureType,
|
|
250
|
+
CreatureSkeleton,
|
|
251
|
+
CreatureSize,
|
|
252
|
+
CreatureReaction,
|
|
253
|
+
CreatureBody,
|
|
254
|
+
CreatureTemperament,
|
|
255
|
+
CreatureSenses,
|
|
256
|
+
CreatureAbility,
|
|
257
|
+
CreaturePresentation,
|
|
258
|
+
CreatureLayers,
|
|
259
|
+
CreatureTuningScalar,
|
|
260
|
+
CreatureTuningValue,
|
|
261
|
+
CreatureTuning,
|
|
262
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import type { CreatureSkeleton } from './creature-layers.ts'
|
|
2
|
+
|
|
3
|
+
interface SkeletonChain {
|
|
4
|
+
readonly parent: string
|
|
5
|
+
readonly bones: readonly string[]
|
|
6
|
+
}
|
|
7
|
+
interface SkeletonSocket {
|
|
8
|
+
readonly bone: string
|
|
9
|
+
readonly at: readonly [number, number, number]
|
|
10
|
+
}
|
|
11
|
+
interface SkeletonVolume {
|
|
12
|
+
readonly part: string
|
|
13
|
+
readonly bone: string
|
|
14
|
+
readonly shape: 'sphere' | 'capsule'
|
|
15
|
+
readonly radius: number
|
|
16
|
+
readonly halfLength: number
|
|
17
|
+
readonly axis: 'y' | 'z'
|
|
18
|
+
readonly multiplier: number
|
|
19
|
+
}
|
|
20
|
+
/** Bone names are wire-format names after the SDK's import mapping. */
|
|
21
|
+
interface SkeletonContract {
|
|
22
|
+
readonly root: string
|
|
23
|
+
readonly chains: Readonly<Record<string, SkeletonChain>>
|
|
24
|
+
readonly sockets: Readonly<Record<string, SkeletonSocket>>
|
|
25
|
+
readonly lock: string
|
|
26
|
+
readonly volumes: readonly SkeletonVolume[]
|
|
27
|
+
readonly clips: readonly string[]
|
|
28
|
+
}
|
|
29
|
+
const ZERO = 0
|
|
30
|
+
const ONE = 1
|
|
31
|
+
const HEAD_MULTIPLIER = 2
|
|
32
|
+
const BODY_RADIUS = 0.35
|
|
33
|
+
const BODY_HALF_LENGTH = 0.5
|
|
34
|
+
const MIN_VOLUME_RADIUS = 0.3
|
|
35
|
+
const MOUTH_FORWARD = 0.2
|
|
36
|
+
const SEAT_HEIGHT = 0.15
|
|
37
|
+
const ORIGIN: readonly [number, number, number] = [ZERO, ZERO, ZERO]
|
|
38
|
+
const CLIPS: readonly string[] = ['idle', 'walk', 'run', 'attack', 'hit', 'die']
|
|
39
|
+
|
|
40
|
+
function socket(bone: string): SkeletonSocket {
|
|
41
|
+
return { bone, at: ORIGIN }
|
|
42
|
+
}
|
|
43
|
+
function bodyVolume(bone: string, axis: 'y' | 'z'): SkeletonVolume {
|
|
44
|
+
return {
|
|
45
|
+
part: 'body',
|
|
46
|
+
bone,
|
|
47
|
+
shape: 'capsule',
|
|
48
|
+
radius: BODY_RADIUS,
|
|
49
|
+
halfLength: BODY_HALF_LENGTH,
|
|
50
|
+
axis,
|
|
51
|
+
multiplier: ONE,
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const HEAD: SkeletonVolume = {
|
|
55
|
+
part: 'head',
|
|
56
|
+
bone: 'head',
|
|
57
|
+
shape: 'sphere',
|
|
58
|
+
radius: MIN_VOLUME_RADIUS,
|
|
59
|
+
halfLength: ZERO,
|
|
60
|
+
axis: 'y',
|
|
61
|
+
multiplier: HEAD_MULTIPLIER,
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** The quadruped keeps today's engine gait names, including front/back leg joints. */
|
|
65
|
+
const QUADRUPED: SkeletonContract = {
|
|
66
|
+
root: 'body',
|
|
67
|
+
chains: {
|
|
68
|
+
neck: { parent: 'body', bones: ['neck1', 'neck2', 'head'] },
|
|
69
|
+
tail: { parent: 'body', bones: ['tail'] },
|
|
70
|
+
'front.L': {
|
|
71
|
+
parent: 'body',
|
|
72
|
+
bones: ['FL_shoulder', 'FL_carpus', 'FL_fetlock'],
|
|
73
|
+
},
|
|
74
|
+
'front.R': {
|
|
75
|
+
parent: 'body',
|
|
76
|
+
bones: ['FR_shoulder', 'FR_carpus', 'FR_fetlock'],
|
|
77
|
+
},
|
|
78
|
+
'back.L': { parent: 'body', bones: ['BL_hip', 'BL_stifle', 'BL_hock'] },
|
|
79
|
+
'back.R': { parent: 'body', bones: ['BR_hip', 'BR_stifle', 'BR_hock'] },
|
|
80
|
+
},
|
|
81
|
+
sockets: {
|
|
82
|
+
head: socket('head'),
|
|
83
|
+
chest: socket('body'),
|
|
84
|
+
back: socket('body'),
|
|
85
|
+
mouth: { bone: 'head', at: [ZERO, ZERO, MOUTH_FORWARD] },
|
|
86
|
+
seat: { bone: 'body', at: [ZERO, SEAT_HEIGHT, ZERO] },
|
|
87
|
+
tail: socket('tail'),
|
|
88
|
+
},
|
|
89
|
+
lock: 'chest',
|
|
90
|
+
volumes: [bodyVolume('body', 'z'), HEAD],
|
|
91
|
+
clips: CLIPS,
|
|
92
|
+
}
|
|
93
|
+
/** An identity body root retains the existing actor root contract. */
|
|
94
|
+
const BIPED: SkeletonContract = {
|
|
95
|
+
root: 'body',
|
|
96
|
+
chains: {
|
|
97
|
+
spine: {
|
|
98
|
+
parent: 'body',
|
|
99
|
+
bones: ['hips', 'spine', 'chest', 'neck', 'head'],
|
|
100
|
+
},
|
|
101
|
+
'arm.L': { parent: 'chest', bones: ['upperArm.L', 'forearm.L', 'hand.L'] },
|
|
102
|
+
'arm.R': { parent: 'chest', bones: ['upperArm.R', 'forearm.R', 'hand.R'] },
|
|
103
|
+
'leg.L': { parent: 'hips', bones: ['thigh.L', 'shin.L', 'foot.L'] },
|
|
104
|
+
'leg.R': { parent: 'hips', bones: ['thigh.R', 'shin.R', 'foot.R'] },
|
|
105
|
+
},
|
|
106
|
+
sockets: {
|
|
107
|
+
head: socket('head'),
|
|
108
|
+
chest: socket('chest'),
|
|
109
|
+
back: socket('chest'),
|
|
110
|
+
mouth: { bone: 'head', at: [ZERO, ZERO, MOUTH_FORWARD] },
|
|
111
|
+
'hand.L': socket('hand.L'),
|
|
112
|
+
'hand.R': socket('hand.R'),
|
|
113
|
+
},
|
|
114
|
+
lock: 'chest',
|
|
115
|
+
volumes: [bodyVolume('chest', 'y'), HEAD],
|
|
116
|
+
clips: CLIPS,
|
|
117
|
+
}
|
|
118
|
+
const CREATURE_SKELETONS: Readonly<Record<CreatureSkeleton, SkeletonContract>> =
|
|
119
|
+
{
|
|
120
|
+
quadruped: QUADRUPED,
|
|
121
|
+
biped: BIPED,
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/** Importers and posers share this list, rather than inferring a creature kind. */
|
|
125
|
+
function skeletonBones(
|
|
126
|
+
contract: Readonly<SkeletonContract>,
|
|
127
|
+
): readonly string[] {
|
|
128
|
+
return [
|
|
129
|
+
contract.root,
|
|
130
|
+
...Object.values(contract.chains).flatMap(
|
|
131
|
+
(chain: Readonly<SkeletonChain>): readonly string[] => chain.bones,
|
|
132
|
+
),
|
|
133
|
+
]
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export { CREATURE_SKELETONS, MIN_VOLUME_RADIUS, skeletonBones }
|
|
137
|
+
export type { SkeletonChain, SkeletonSocket, SkeletonVolume, SkeletonContract }
|
package/src/format/minimap.ts
CHANGED
|
@@ -243,6 +243,8 @@ const tier = v.objectWithRest({aa: v.exactOptional(v.picklist(['fxaa', 'smaa', '
|
|
|
243
243
|
animalHullBatch: v.exactOptional(v.boolean()),
|
|
244
244
|
textures: v.exactOptional(v.picklist(['img', 'ktx2']))}, number);
|
|
245
245
|
const strings = v.pipe(v.array(text), v.maxLength(256));
|
|
246
|
+
/** A POI's respawn opt-out (TEMPLATE-E2E): `false` is no respawn place. */
|
|
247
|
+
const optionalFlag = v.exactOptional(v.boolean())
|
|
246
248
|
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({
|
|
247
249
|
bindings,
|
|
248
250
|
boot: v.exactOptional(v.strictObject({barrier: v.exactOptional(v.boolean()), cullBeforeFirstDraw: v.exactOptional(v.boolean()),
|
|
@@ -298,7 +300,7 @@ export const ManifestMetadataSchema: v.StrictObjectSchema<{ readonly bindings: v
|
|
|
298
300
|
bloomThreshold: number, shadowTint: rgb, highTint: rgb, lift: rgb, gain: rgb, gamma: number }),
|
|
299
301
|
horizon: v.exactOptional(v.strictObject({ rings: v.pipe(v.array(ring), v.maxLength(32)), cloudSea: v.boolean() })),
|
|
300
302
|
minimap: v.strictObject({ image, openWater: v.exactOptional(v.strictObject({level: number, deepDepth: number})), outside: v.exactOptional(text) }),
|
|
301
|
-
pois: v.pipe(v.array(v.strictObject({ id: text, name: text, x: number, z: number, r: v.exactOptional(number) })), v.maxLength(256)),
|
|
303
|
+
pois: v.pipe(v.array(v.strictObject({ id: text, name: text, x: number, z: number, r: v.exactOptional(number), respawn: optionalFlag })), v.maxLength(256)),
|
|
302
304
|
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}))) }),
|
|
303
305
|
captureProbes: v.exactOptional(v.array(v.strictObject({name: text, x: number, z: number, yaw: number, pitch: number}))),
|
|
304
306
|
next: v.exactOptional(text), debugOptions: v.exactOptional(strings), bodyShadow: v.exactOptional(v.boolean()),
|
|
@@ -840,6 +842,8 @@ export interface ManifestMetadataFields {
|
|
|
840
842
|
x: number;
|
|
841
843
|
z: number;
|
|
842
844
|
r?: number;
|
|
845
|
+
/** False keeps a fallen player from coming back here (a boss pit); absent or true, the POI is a respawn place */
|
|
846
|
+
respawn?: boolean;
|
|
843
847
|
})[];
|
|
844
848
|
explore: {
|
|
845
849
|
art: {
|
package/src/format/rows.ts
CHANGED
|
@@ -3,6 +3,8 @@ import * as v from 'valibot';
|
|
|
3
3
|
import { isJsonData } from './json.ts';
|
|
4
4
|
import { sketchReference } from './sketch.ts';
|
|
5
5
|
import { JournalRowSchema, journalRowRules } from './compendiumRows.ts';
|
|
6
|
+
import { CreatureTypeSchema, CreatureBodySchema, CreatureTemperamentSchema, CreatureSensesSchema, CreatureAbilitySchema, CreaturePresentationSchema } from './creature-layers.ts';
|
|
7
|
+
import type { CreatureLayers } from './creature-layers.ts';
|
|
6
8
|
|
|
7
9
|
const id = v.pipe(v.string(), v.regex(/^[a-z][a-zA-Z0-9.:-]*$/u), v.maxLength(128));
|
|
8
10
|
const text = v.pipe(v.string(), v.maxLength(4096));
|
|
@@ -37,8 +39,13 @@ const variant = v.strictObject({ id, label: text, rarity: v.picklist(['common',
|
|
|
37
39
|
const flight = v.strictObject({ altitude: v.pipe(finite, v.minValue(-250), v.maxValue(250)),
|
|
38
40
|
above: v.exactOptional(v.picklist(['ground', 'world'])), climbRate: v.pipe(positive, v.maxValue(30)), diveRate: v.pipe(positive, v.maxValue(30)),
|
|
39
41
|
lockRange: v.exactOptional(v.pipe(positive, v.maxValue(600))), bank: v.exactOptional(v.pipe(finite, v.check(n => n > 0 && n < Math.PI / 2, 'flight bank between 0 and pi/2'))) });
|
|
42
|
+
const MAX_ABILITIES = 32;
|
|
43
|
+
const abilities = v.pipe(v.array(CreatureAbilitySchema), v.maxLength(MAX_ABILITIES));
|
|
40
44
|
const species = v.strictObject({ id, kind: id, label: text, aggressive: v.boolean(), lockable: v.boolean(), dims, flight: v.exactOptional(flight),
|
|
41
|
-
variants: v.pipe(v.array(variant), v.minLength(1), v.maxLength(64))
|
|
45
|
+
variants: v.pipe(v.array(variant), v.minLength(1), v.maxLength(64)),
|
|
46
|
+
type: v.exactOptional(CreatureTypeSchema), body: v.exactOptional(CreatureBodySchema),
|
|
47
|
+
temperament: v.exactOptional(CreatureTemperamentSchema), senses: v.exactOptional(CreatureSensesSchema),
|
|
48
|
+
abilities: v.exactOptional(abilities), presentation: v.exactOptional(CreaturePresentationSchema) });
|
|
42
49
|
const parameter = v.union([finite, v.boolean(), text, v.pipe(v.array(finite), v.maxLength(16))]);
|
|
43
50
|
const look = v.strictObject({ id, species: id, recipe: id, material: v.optional(v.nullable(id), null), parameters: v.record(id, parameter),
|
|
44
51
|
animation: v.strictObject({ recipe: id, parameters: v.record(id, parameter) }) });
|
|
@@ -54,7 +61,7 @@ const raw: v.StrictObjectSchema<{ readonly strikes: v.SchemaWithPipe<readonly [v
|
|
|
54
61
|
/** Pure author rows: numeric weights, state output tables, clocks and registered view/presentation recipes. */
|
|
55
62
|
|
|
56
63
|
/** Reference, uniqueness and complete clock/weather transition rules for data rows. */
|
|
57
|
-
|
|
64
|
+
function rowRules(rows: ShardRows): string[] {
|
|
58
65
|
const errors: string[] = [];
|
|
59
66
|
for (const list of Object.values(rows)) if (new Set(list.map((r) => r.id)).size !== list.length) errors.push('unique row ids');
|
|
60
67
|
for (const row of rows.loot) if (row.economy !== undefined && !('kind' in row.economy)) errors.push(...lootEconomyRules(row.economy));
|
|
@@ -65,6 +72,16 @@ export function rowRules(rows: ShardRows): string[] {
|
|
|
65
72
|
for (const d of rows.days) if (d.schedule[0]?.from !== 0 || d.schedule.at(-1)?.to !== 24 || d.schedule.some((s, i) => s.from >= s.to || (i > 0 && d.schedule[i - 1]?.to !== s.from))) errors.push('complete ordered day schedule');
|
|
66
73
|
const speciesIds = new Set(rows.species.map((s) => s.id));
|
|
67
74
|
for (const s of rows.species) if (new Set(s.variants.map((r) => r.id)).size !== s.variants.length || s.variants.some((r) => r.scale[1] > 10)) errors.push('species variants');
|
|
75
|
+
const strikeIds = new Set<string>();
|
|
76
|
+
for (const strikeRow of rows.strikes) { strikeIds.add(strikeRow.id); }
|
|
77
|
+
const lookIds = new Set<string>();
|
|
78
|
+
for (const lookRow of rows.looks) { lookIds.add(lookRow.id); }
|
|
79
|
+
for (const speciesRow of rows.species) {
|
|
80
|
+
for (const ability of speciesRow.abilities ?? []) {
|
|
81
|
+
if (!strikeIds.has(ability.use)) { errors.push(`Unknown creature ability: ${ability.use}`); }
|
|
82
|
+
}
|
|
83
|
+
if (speciesRow.body !== undefined && !lookIds.has(speciesRow.body.look)) { errors.push(`Unknown creature look: ${speciesRow.body.look}`); }
|
|
84
|
+
}
|
|
68
85
|
for (const l of rows.looks) if (!speciesIds.has(l.species)) errors.push('look species');
|
|
69
86
|
for (const c of rows.compendiums) {
|
|
70
87
|
if ('kind' in c) { errors.push(...journalRowRules(c)); continue; }
|
|
@@ -73,14 +90,25 @@ export function rowRules(rows: ShardRows): string[] {
|
|
|
73
90
|
}
|
|
74
91
|
return errors;
|
|
75
92
|
}
|
|
93
|
+
function rowMessage(issue: Readonly<{ input: unknown }>): string {
|
|
94
|
+
const data = v.parse(raw, issue.input);
|
|
95
|
+
const reasons = rowRules(data);
|
|
96
|
+
return `row reference rules: ${reasons.join('; ')}`;
|
|
97
|
+
}
|
|
76
98
|
/** The independent JSON check runs before strict row schemas; functions/accessors/cycles never become data. */
|
|
77
|
-
|
|
99
|
+
const RowsSchema: v.SchemaWithPipe<readonly [v.UnknownSchema, v.CheckAction<unknown, 'JSON-only rows'>, typeof raw, v.CheckAction<ShardRows, typeof rowMessage>]> = v.pipe(v.unknown(), v.check(isJsonData, 'JSON-only rows'), raw, v.check((rows) => rowRules(rows).length === 0, rowMessage));
|
|
78
100
|
/** Validate rows at the author boundary, before JSON serialization can erase closures. */
|
|
79
|
-
|
|
101
|
+
function parseRows(input: unknown): ShardRows { return v.parse(RowsSchema, input); }
|
|
80
102
|
|
|
81
103
|
/** Admitted author data independent of validator implementation metadata. */
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
104
|
+
type StrikeRowsInput = StrikeRows;
|
|
105
|
+
interface StrikeRows { id: string; shape: ({ kind: 'point'; radius: number; }) | ({ kind: 'sphere'; radius: number; }) | ({ kind: 'lane'; length: number; width: number; }) | ({ kind: 'arc'; radius: number; halfAngle: number; }) | ({ kind: 'wedge'; length: number; halfAngle: number; }) | ({ kind: 'ring'; inner: number; outer: number; }); windup: number; active: number; recover: number; cooldown: number; range: number; damage: number; tags: (`${string}.${string}`)[]; weight: number; speed: number; }
|
|
106
|
+
interface ShardRowsInput { strikes: (StrikeRowsInput)[]; weather: ({ id: string; states: ({ id: string; next: string; length: [number, number]; numbers: { overcast: number; rain: number; wet: number; wind: number; fog: number; }; })[]; initial: { overcast: number; rain: number; wet: number; wind: number; fog: number; }; soak: number; dry: number; modes: ({ id: string; hold: (string) | null; at: number; dry: boolean; })[]; })[]; days: ({ id: string; units: 'hour'; start: number; schedule: ({ phase: 'dawn' | 'day' | 'golden' | 'dusk' | 'night'; from: number; to: number; minutes: number; })[]; sun: { maxElevation: number; azimuthOffset: number; }; fixed: { midday: number; golden: number; sunset: number; night: number; }; presets: { dawn: number; noon: number; dusk: number; night: number; }; })[]; species: SpeciesRow[]; looks: ({ id: string; species: string; recipe: string; material?: (string) | null | undefined; parameters: Record<string, (number) | (boolean) | (string) | ((number)[])>; animation: { recipe: string; parameters: Record<string, (number) | (boolean) | (string) | ((number)[])>; }; })[]; compendiums: (({ id: string; className: string; title: string; tabs: ({ id: string; label: string; })[]; stamp: string; stats: ({ label: string; value: string; })[]; entries: ({ id: string; kind: 'species'; tab: string; name: string; notes: string; sketch: string; species: string; })[]; }) | (v.InferInput<typeof JournalRowSchema>))[]; loot: (({ id: string; gear: 'purse.coins'; finds: null; marks: null; charted: boolean; chime: string; economy?: v.InferInput<typeof LootEconomySchema>; }) | ({ id: string; economy: v.InferInput<typeof BarterEconomySchema>; }))[]; }
|
|
85
107
|
// oxlint-disable-next-line typescript/consistent-type-definitions -- Object.values needs the original implicit dictionary contract for row validation.
|
|
86
|
-
|
|
108
|
+
type ShardRows = { strikes: (StrikeRows)[]; weather: ({ id: string; states: ({ id: string; next: string; length: [number, number]; numbers: { overcast: number; rain: number; wet: number; wind: number; fog: number; }; })[]; initial: { overcast: number; rain: number; wet: number; wind: number; fog: number; }; soak: number; dry: number; modes: ({ id: string; hold: (string) | null; at: number; dry: boolean; })[]; })[]; days: ({ id: string; units: 'hour'; start: number; schedule: ({ phase: 'dawn' | 'day' | 'golden' | 'dusk' | 'night'; from: number; to: number; minutes: number; })[]; sun: { maxElevation: number; azimuthOffset: number; }; fixed: { midday: number; golden: number; sunset: number; night: number; }; presets: { dawn: number; noon: number; dusk: number; night: number; }; })[]; species: SpeciesRow[]; looks: ({ id: string; species: string; recipe: string; material: (string) | null; parameters: Record<string, (number) | (boolean) | (string) | ((number)[])>; animation: { recipe: string; parameters: Record<string, (number) | (boolean) | (string) | ((number)[])>; }; })[]; compendiums: (({ id: string; className: string; title: string; tabs: ({ id: string; label: string; })[]; stamp: string; stats: ({ label: string; value: string; })[]; entries: ({ id: string; kind: 'species'; tab: string; name: string; notes: string; sketch: string; species: string; })[]; }) | (v.InferOutput<typeof JournalRowSchema>))[]; loot: (({ id: string; gear: 'purse.coins'; finds: null; marks: null; charted: boolean; chime: string; economy?: v.InferOutput<typeof LootEconomySchema>; }) | ({ id: string; economy: v.InferOutput<typeof BarterEconomySchema>; }))[]; };
|
|
109
|
+
|
|
110
|
+
/** A species keeps its old fields, with optional explicit creature layers. */
|
|
111
|
+
interface SpeciesRow extends CreatureLayers { id: string; kind: string; label: string; aggressive: boolean; lockable: boolean; dims: { bodyY: number; bodyHalfLen: number; bodyRadius: number; headRadius: number; legLen: number; feet: ([number, number])[]; halfWidth: number; }; flight?: { altitude: number; above?: 'ground' | 'world'; climbRate: number; diveRate: number; lockRange?: number; bank?: number; }; variants: ({ id: string; label: string; rarity: 'common' | 'uncommon' | 'rare' | 'legendary'; weight: number; scale: [number, number]; hp: number; mods: { speed: number; chargeDist: number; damageTaken: number; chargeDamage: number; relentless: boolean; }; })[]; }
|
|
112
|
+
|
|
113
|
+
export { rowRules, RowsSchema, parseRows };
|
|
114
|
+
export type { StrikeRowsInput, StrikeRows, ShardRowsInput, ShardRows, SpeciesRow };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
// Validator output rows retain the format's mutable public data types.
|
|
2
|
+
/* oxlint-disable typescript/prefer-readonly-parameter-types */
|
|
3
|
+
import { parse, safeParse } from 'valibot'
|
|
4
|
+
|
|
5
|
+
import { parseSkinBindings, parseSkinRows } from './skinData.ts'
|
|
6
|
+
import {
|
|
7
|
+
SKIN_LOOK_RECIPE,
|
|
8
|
+
SKIN_CLIPS_RECIPE,
|
|
9
|
+
SkinLookParametersSchema,
|
|
10
|
+
SkinClipParametersSchema,
|
|
11
|
+
ShardSkinFileSchema,
|
|
12
|
+
} from './skins.ts'
|
|
13
|
+
|
|
14
|
+
import type { ShardRows } from './rows.ts'
|
|
15
|
+
import type { SkinBinding, SkinRow } from './skinData.ts'
|
|
16
|
+
import type { SkinLookParameters } from './skins.ts'
|
|
17
|
+
|
|
18
|
+
/** Parse the exact skin look and animation parameters. */
|
|
19
|
+
function skinLookParameters(
|
|
20
|
+
row: ShardRows['looks'][number],
|
|
21
|
+
): SkinLookParameters {
|
|
22
|
+
if (row.recipe !== SKIN_LOOK_RECIPE) {
|
|
23
|
+
throw new Error(`look ${row.id}: not a skin look`)
|
|
24
|
+
}
|
|
25
|
+
if (row.animation.recipe !== SKIN_CLIPS_RECIPE) {
|
|
26
|
+
throw new Error(
|
|
27
|
+
`look ${row.id}: a skin look animates with ${SKIN_CLIPS_RECIPE}`,
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
const look = safeParse(SkinLookParametersSchema, row.parameters)
|
|
31
|
+
const clips = safeParse(SkinClipParametersSchema, row.animation.parameters)
|
|
32
|
+
if (!look.success || !clips.success) {
|
|
33
|
+
throw new Error(`look ${row.id}: invalid skin parameters`)
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
skin: look.output.skin,
|
|
37
|
+
attackSpan: clips.output.attackSpan,
|
|
38
|
+
...(look.output.variants === undefined
|
|
39
|
+
? {}
|
|
40
|
+
: { variants: look.output.variants }),
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/** Decode the rig row and binding together. */
|
|
45
|
+
function parseSkinFile(bytes: Uint8Array): {
|
|
46
|
+
row: SkinRow
|
|
47
|
+
binding: SkinBinding
|
|
48
|
+
} {
|
|
49
|
+
const file = parse(
|
|
50
|
+
ShardSkinFileSchema,
|
|
51
|
+
JSON.parse(new TextDecoder().decode(bytes)),
|
|
52
|
+
)
|
|
53
|
+
const [row] = parseSkinRows([file.row])
|
|
54
|
+
if (row === undefined) {
|
|
55
|
+
throw new Error('skin file: no row')
|
|
56
|
+
}
|
|
57
|
+
const [binding] = parseSkinBindings([file.binding], [row])
|
|
58
|
+
if (binding === undefined) {
|
|
59
|
+
throw new Error('skin file: no binding')
|
|
60
|
+
}
|
|
61
|
+
return { row, binding }
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export { parseSkinFile, skinLookParameters }
|
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
// Validator output rows deliberately retain the format's mutable public data types.
|
|
2
|
+
/* oxlint-disable typescript/prefer-readonly-parameter-types */
|
|
3
|
+
// The portable library targets ES2022; sort only new arrays.
|
|
4
|
+
/* oxlint-disable unicorn/no-array-sort */
|
|
5
|
+
import { parse } from 'valibot'
|
|
6
|
+
|
|
7
|
+
import { parseSkinFile, skinLookParameters } from './skin-file.ts'
|
|
8
|
+
import { SkinVariantsSchema } from './skins.ts'
|
|
9
|
+
import { validationSourceBytes } from './validationReceipt.ts'
|
|
10
|
+
|
|
11
|
+
import type { ShardRows } from './rows.ts'
|
|
12
|
+
import type { Shardfile } from './shardSchema.ts'
|
|
13
|
+
import type { SkinBinding, SkinRow } from './skinData.ts'
|
|
14
|
+
|
|
15
|
+
interface ResolvedSkinFile {
|
|
16
|
+
readonly hash: string
|
|
17
|
+
readonly row: SkinRow
|
|
18
|
+
readonly binding: SkinBinding
|
|
19
|
+
}
|
|
20
|
+
interface SkinLookFiles {
|
|
21
|
+
readonly skin: ResolvedSkinFile
|
|
22
|
+
readonly variants?: ReadonlyMap<string, ResolvedSkinFile>
|
|
23
|
+
}
|
|
24
|
+
type Source = Pick<Shardfile, 'rows' | 'files'>
|
|
25
|
+
type Look = ShardRows['looks'][number]
|
|
26
|
+
const FIRST = 0
|
|
27
|
+
const SINGLE = 1
|
|
28
|
+
|
|
29
|
+
function skinContract({ row, binding }: ResolvedSkinFile): string {
|
|
30
|
+
return new TextDecoder().decode(
|
|
31
|
+
validationSourceBytes({
|
|
32
|
+
family: row.family,
|
|
33
|
+
skeleton: row.rig.skeleton,
|
|
34
|
+
joints: [...(row.rig.joints[FIRST] ?? [])].sort(),
|
|
35
|
+
clips: [...row.rig.clips].sort(),
|
|
36
|
+
sockets: [...row.rig.sockets].sort(),
|
|
37
|
+
material: binding.material,
|
|
38
|
+
materials: binding.materials ?? {},
|
|
39
|
+
}),
|
|
40
|
+
)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function readSkinFile(
|
|
44
|
+
files: ReadonlyMap<string, Source['files'][number]>,
|
|
45
|
+
assets: ReadonlyMap<string, Uint8Array>,
|
|
46
|
+
hash: string,
|
|
47
|
+
): ResolvedSkinFile {
|
|
48
|
+
const file = files.get(hash)
|
|
49
|
+
const bytes = assets.get(hash)
|
|
50
|
+
if (file?.kind !== 'json' || bytes === undefined) {
|
|
51
|
+
throw new Error('skin file missing')
|
|
52
|
+
}
|
|
53
|
+
const skin = { hash, ...parseSkinFile(bytes) }
|
|
54
|
+
if (
|
|
55
|
+
file.dependencies.length !== SINGLE ||
|
|
56
|
+
file.dependencies[FIRST] !== skin.row.file ||
|
|
57
|
+
files.get(skin.row.file)?.kind !== 'glb'
|
|
58
|
+
) {
|
|
59
|
+
throw new Error('skin rig dependency mismatch')
|
|
60
|
+
}
|
|
61
|
+
return skin
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function skinReader(
|
|
65
|
+
source: Source,
|
|
66
|
+
assets: ReadonlyMap<string, Uint8Array>,
|
|
67
|
+
): (hash: string) => ResolvedSkinFile {
|
|
68
|
+
const files = new Map(
|
|
69
|
+
source.files.map((file): [string, Source['files'][number]] => [
|
|
70
|
+
file.hash,
|
|
71
|
+
file,
|
|
72
|
+
]),
|
|
73
|
+
)
|
|
74
|
+
const parsed = new Map<string, ResolvedSkinFile>()
|
|
75
|
+
return (hash: string): ResolvedSkinFile => {
|
|
76
|
+
const known = parsed.get(hash)
|
|
77
|
+
if (known !== undefined) {
|
|
78
|
+
return known
|
|
79
|
+
}
|
|
80
|
+
const skin = readSkinFile(files, assets, hash)
|
|
81
|
+
parsed.set(hash, skin)
|
|
82
|
+
return skin
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function checkCoverage(
|
|
87
|
+
skins: Readonly<Record<string, string>>,
|
|
88
|
+
ids: readonly string[],
|
|
89
|
+
): void {
|
|
90
|
+
const expected = new Set(ids)
|
|
91
|
+
const keys = Object.keys(skins)
|
|
92
|
+
if (
|
|
93
|
+
keys.length !== expected.size ||
|
|
94
|
+
keys.some((key): boolean => !expected.has(key))
|
|
95
|
+
) {
|
|
96
|
+
throw new Error('variant table must name every species variant exactly')
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function checkDependencies(
|
|
101
|
+
skins: Readonly<Record<string, string>>,
|
|
102
|
+
actual: readonly string[],
|
|
103
|
+
defaultHash: string,
|
|
104
|
+
): void {
|
|
105
|
+
const dependencies = [...new Set(Object.values(skins))].sort()
|
|
106
|
+
if (
|
|
107
|
+
dependencies.length !== actual.length ||
|
|
108
|
+
[...actual]
|
|
109
|
+
.sort()
|
|
110
|
+
.some((hash, index): boolean => hash !== dependencies[index])
|
|
111
|
+
) {
|
|
112
|
+
throw new Error('variant table dependencies differ')
|
|
113
|
+
}
|
|
114
|
+
if (!dependencies.includes(defaultHash)) {
|
|
115
|
+
throw new Error('variant table must include its default skin')
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function variantTable(
|
|
120
|
+
source: Source,
|
|
121
|
+
look: Look,
|
|
122
|
+
{
|
|
123
|
+
assets,
|
|
124
|
+
parameters,
|
|
125
|
+
}: {
|
|
126
|
+
assets: ReadonlyMap<string, Uint8Array>
|
|
127
|
+
parameters: { variants: string; skin: string }
|
|
128
|
+
},
|
|
129
|
+
): Readonly<Record<string, string>> {
|
|
130
|
+
const table = source.files.find(
|
|
131
|
+
(file): boolean => file.hash === parameters.variants,
|
|
132
|
+
)
|
|
133
|
+
const bytes = assets.get(parameters.variants)
|
|
134
|
+
if (table?.kind !== 'json' || bytes === undefined) {
|
|
135
|
+
throw new Error(`skin look ${look.id}: variant table missing`)
|
|
136
|
+
}
|
|
137
|
+
const variants = parse(
|
|
138
|
+
SkinVariantsSchema,
|
|
139
|
+
JSON.parse(new TextDecoder().decode(bytes)),
|
|
140
|
+
)
|
|
141
|
+
const species = source.rows.species.find(
|
|
142
|
+
(row): boolean => row.id === look.species,
|
|
143
|
+
)
|
|
144
|
+
checkCoverage(
|
|
145
|
+
variants.skins,
|
|
146
|
+
(species?.variants ?? []).map((row): string => row.id),
|
|
147
|
+
)
|
|
148
|
+
checkDependencies(variants.skins, table.dependencies, parameters.skin)
|
|
149
|
+
return variants.skins
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function resolveVariants(
|
|
153
|
+
table: Readonly<Record<string, string>>,
|
|
154
|
+
skin: ResolvedSkinFile,
|
|
155
|
+
read: (hash: string) => ResolvedSkinFile,
|
|
156
|
+
): ReadonlyMap<string, ResolvedSkinFile> {
|
|
157
|
+
const contract = skinContract(skin)
|
|
158
|
+
const variants = new Map<string, ResolvedSkinFile>()
|
|
159
|
+
for (const [variant, hash] of Object.entries(table)) {
|
|
160
|
+
const value = read(hash)
|
|
161
|
+
if (skinContract(value) !== contract) {
|
|
162
|
+
throw new Error(`incompatible variant rig or material: ${variant}`)
|
|
163
|
+
}
|
|
164
|
+
variants.set(variant, value)
|
|
165
|
+
}
|
|
166
|
+
return variants
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/** Resolve exact variant coverage and compatible rig/material declarations once at admission/load. */
|
|
170
|
+
function resolveSkinLookFiles(
|
|
171
|
+
source: Source,
|
|
172
|
+
look: Look,
|
|
173
|
+
assets: ReadonlyMap<string, Uint8Array>,
|
|
174
|
+
): SkinLookFiles {
|
|
175
|
+
const parameters = skinLookParameters(look)
|
|
176
|
+
const read = skinReader(source, assets)
|
|
177
|
+
const skin = read(parameters.skin)
|
|
178
|
+
if (parameters.variants === undefined) {
|
|
179
|
+
return { skin }
|
|
180
|
+
}
|
|
181
|
+
const table = variantTable(source, look, {
|
|
182
|
+
assets,
|
|
183
|
+
parameters: { variants: parameters.variants, skin: parameters.skin },
|
|
184
|
+
})
|
|
185
|
+
const variants = resolveVariants(table, skin, read)
|
|
186
|
+
return { skin, variants }
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export { resolveSkinLookFiles }
|
|
190
|
+
export type { ResolvedSkinFile, SkinLookFiles }
|
package/src/format/skinAssets.ts
CHANGED
|
@@ -11,39 +11,28 @@
|
|
|
11
11
|
* `attackSpan` is the attack duration the export sampled the attack clip with (seconds).
|
|
12
12
|
*/
|
|
13
13
|
import * as v from 'valibot';
|
|
14
|
-
import {
|
|
15
|
-
import type {
|
|
14
|
+
import { validateCreatureBones } from './skinData.ts';
|
|
15
|
+
import type { SkinRow } from './skinData.ts';
|
|
16
16
|
import type { Shardfile } from './shardSchema.ts';
|
|
17
17
|
import { parseGlbData as parseGlb } from './glbCost.ts';
|
|
18
18
|
import { skinLayerDecoded } from './skinLayers.ts';
|
|
19
19
|
import { MaterialsSchema } from './materials.ts';
|
|
20
20
|
import { SkinGlbMaterialsSchema, SkinPrimitiveSchema, skinMaterialsFault, skinPartsFault, skinPrimitiveCount } from './skin-materials.ts';
|
|
21
21
|
|
|
22
|
-
import { SKIN_LOOK_RECIPE, SKIN_CLIPS_RECIPE
|
|
22
|
+
import { SKIN_LOOK_RECIPE, SKIN_CLIPS_RECIPE } from './skins.ts';
|
|
23
|
+
import type { SkinLookParameters } from './skins.ts';
|
|
24
|
+
import { resolveSkinLookFiles } from './skin-variants.ts';
|
|
25
|
+
import { skinLookParameters } from './skin-file.ts';
|
|
23
26
|
|
|
24
|
-
/** Parse a `platform.skin` look row's parameters (throws on anything else). */
|
|
25
|
-
export function skinLookParameters(row: ShardRows['looks'][number]): SkinLookParameters {
|
|
26
|
-
if (row.recipe !== SKIN_LOOK_RECIPE) throw new Error(`look ${row.id}: not a skin look`);
|
|
27
|
-
if (row.animation.recipe !== SKIN_CLIPS_RECIPE) throw new Error(`look ${row.id}: a skin look animates with ${SKIN_CLIPS_RECIPE}`);
|
|
28
|
-
const look = v.safeParse(SkinLookParametersSchema, row.parameters), clips = v.safeParse(SkinClipParametersSchema, row.animation.parameters);
|
|
29
|
-
if (!look.success || !clips.success) throw new Error(`look ${row.id}: invalid skin parameters`);
|
|
30
|
-
return { skin: look.output.skin, attackSpan: clips.output.attackSpan };
|
|
31
|
-
}
|
|
32
|
-
/** Decode and validate one skin file's bytes: its rig row and binding, the binding for that row. */
|
|
33
|
-
export function parseSkinFile(bytes: Uint8Array): { row: SkinRow; binding: SkinBinding } {
|
|
34
|
-
const file = v.parse(ShardSkinFileSchema, JSON.parse(new TextDecoder().decode(bytes)));
|
|
35
|
-
const [row] = parseSkinRows([file.row]); if (row === undefined) throw new Error('skin file: no row');
|
|
36
|
-
const [binding] = parseSkinBindings([file.binding], [row]); if (binding === undefined) throw new Error('skin file: no binding');
|
|
37
|
-
return { row, binding };
|
|
38
|
-
}
|
|
39
27
|
/** Shardfile reference rules for skin looks: a library `json` file whose dependencies are exactly its row's `glb`. */
|
|
40
|
-
|
|
28
|
+
function skinLookRules(source: Pick<Shardfile, 'rows' | 'files' | 'library'>): string[] {
|
|
41
29
|
const errors: string[] = [], files = new Map(source.files.map((file) => [file.hash, file]));
|
|
42
30
|
for (const row of source.rows.looks) {
|
|
43
|
-
if (row.recipe !== SKIN_LOOK_RECIPE) { if (row.animation.recipe === SKIN_CLIPS_RECIPE) errors.push('skin clips without a skin look'); continue; }
|
|
44
|
-
let
|
|
45
|
-
const file = files.get(skin), glb = file?.dependencies.length === 1 ? files.get(file.dependencies[0] ?? '') : undefined;
|
|
46
|
-
if (file?.kind !== 'json' || glb?.kind !== 'glb' || !source.library.includes(skin)) errors.push('skin look file references');
|
|
31
|
+
if (row.recipe !== SKIN_LOOK_RECIPE) { if (row.animation.recipe === SKIN_CLIPS_RECIPE) {errors.push('skin clips without a skin look');} continue; }
|
|
32
|
+
let parameters: SkinLookParameters; try { parameters = skinLookParameters(row); } catch { errors.push('skin look parameters'); continue; }
|
|
33
|
+
const { skin, variants } = parameters, file = files.get(skin), glb = file?.dependencies.length === 1 ? files.get(file.dependencies[0] ?? '') : undefined;
|
|
34
|
+
if (file?.kind !== 'json' || glb?.kind !== 'glb' || !source.library.includes(skin)) {errors.push('skin look file references');}
|
|
35
|
+
if (variants !== undefined && (files.get(variants)?.kind !== 'json' || !source.library.includes(variants))) {errors.push('skin variant table references');}
|
|
47
36
|
}
|
|
48
37
|
return errors;
|
|
49
38
|
}
|
|
@@ -58,7 +47,7 @@ const glbRigSchema = v.object({
|
|
|
58
47
|
|
|
59
48
|
/** Check admitted GLB joint order, sockets and clips before a renderer allocates the creature view. */
|
|
60
49
|
function validateRigBytes(glb: Uint8Array, row: SkinRow, parts: Readonly<Record<string, string>> | undefined): void {
|
|
61
|
-
//
|
|
50
|
+
// ParseGlb already bounds and validates the header, JSON chunk and every node/accessor reference.
|
|
62
51
|
const length = new DataView(glb.buffer, glb.byteOffset, glb.byteLength).getUint32(12, true);
|
|
63
52
|
const rig = v.parse(glbRigSchema, JSON.parse(new TextDecoder().decode(glb.subarray(20, 20 + length))));
|
|
64
53
|
function fail(reason: string): never { throw new Error(`skin ${row.id}: ${reason}`); }
|
|
@@ -66,42 +55,47 @@ function validateRigBytes(glb: Uint8Array, row: SkinRow, parts: Readonly<Record<
|
|
|
66
55
|
const meshes = rig.nodes.filter(node => node.skin !== undefined && node.mesh !== undefined);
|
|
67
56
|
const mesh = meshes[0];
|
|
68
57
|
if (meshes.length !== 1 || mesh?.mesh === undefined || mesh.skin === undefined
|
|
69
|
-
|| !skinPrimitiveCount(rig.meshes[mesh.mesh]?.primitives.length)) fail('expected one skinned mesh');
|
|
58
|
+
|| !skinPrimitiveCount(rig.meshes[mesh.mesh]?.primitives.length)) {fail('expected one skinned mesh');}
|
|
70
59
|
const partsFault = skinPartsFault(rig.meshes[mesh.mesh]?.primitives ?? [], rig.materials, parts);
|
|
71
60
|
if (partsFault !== '') { fail(partsFault); }
|
|
72
61
|
const joints = rig.skins[mesh.skin]?.joints.map(index => rig.nodes[index]?.name);
|
|
73
62
|
const expected = row.rig.joints[0];
|
|
74
63
|
if (joints === undefined || expected === undefined || joints.length !== expected.length
|
|
75
|
-
|| joints.some((name, index) => name !== expected[index])) fail('skin joint order differs from bake');
|
|
64
|
+
|| joints.some((name, index) => name !== expected[index])) {fail('skin joint order differs from bake');}
|
|
76
65
|
for (const name of row.rig.sockets) {
|
|
77
|
-
if (named.filter(actual => actual === name).length !== 1) fail(`missing or ambiguous socket ${name}`);
|
|
66
|
+
if (named.filter(actual => actual === name).length !== 1) {fail(`missing or ambiguous socket ${name}`);}
|
|
78
67
|
}
|
|
79
68
|
for (const name of row.rig.clips) {
|
|
80
|
-
if (rig.animations.filter(clip => clip.name === name).length !== 1) fail(`missing or ambiguous clip ${name}`);
|
|
69
|
+
if (rig.animations.filter(clip => clip.name === name).length !== 1) {fail(`missing or ambiguous clip ${name}`);}
|
|
81
70
|
}
|
|
82
71
|
}
|
|
83
72
|
|
|
84
73
|
/** Admit each rig binding and its exact GLB dependency before allocating a client view. */
|
|
85
|
-
|
|
74
|
+
function validateSkinAssets(source: Pick<Shardfile, 'rows' | 'files'> & { readonly look?: Pick<Shardfile['look'], 'materials'> }, assets: ReadonlyMap<string, Uint8Array>): void {
|
|
86
75
|
const files = new Map(source.files.map((file) => [file.hash, file]));
|
|
87
76
|
for (const look of source.rows.looks) {
|
|
88
|
-
if (look.recipe !== SKIN_LOOK_RECIPE) continue;
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
const { row, binding }
|
|
92
|
-
|
|
77
|
+
if (look.recipe !== SKIN_LOOK_RECIPE) {continue;}
|
|
78
|
+
const resolved = resolveSkinLookFiles(source, look, assets);
|
|
79
|
+
const skins = new Map([resolved.skin, ...(resolved.variants?.values() ?? [])].map((skin): [string, typeof resolved.skin] => [skin.hash, skin]));
|
|
80
|
+
for (const { row, binding } of skins.values()) {
|
|
81
|
+
|
|
93
82
|
validateCreatureBones(look.species, row.rig.sockets);
|
|
94
83
|
validateCreatureBones(look.species, row.rig.joints[0] ?? []);
|
|
95
84
|
v.parse(MaterialsSchema, { skin: binding.material });
|
|
96
|
-
const glb = assets.get(row.file)
|
|
97
|
-
if (glb === undefined || declared === undefined) throw new Error('skin GLB missing');
|
|
85
|
+
const glb = assets.get(row.file); const declared = files.get(row.file);
|
|
86
|
+
if (glb === undefined || declared === undefined) {throw new Error('skin GLB missing');}
|
|
98
87
|
const cost = parseGlb(glb);
|
|
99
88
|
validateRigBytes(glb, row, binding.materials);
|
|
100
89
|
const undeclared = skinMaterialsFault(binding.materials, source.look?.materials ?? {});
|
|
101
90
|
if (undeclared !== '') { throw new Error(undeclared); }
|
|
102
91
|
cost.decoded += skinLayerDecoded(binding.poseLayers ?? {}, row.rig.joints[0]?.length ?? 0);
|
|
103
92
|
for (const key of ['decoded', 'gpu', 'triangles', 'draws'] as const) {
|
|
104
|
-
if (cost[key] > row.cost[key] || cost[key] > declared[key]) throw new Error('skin cost understated');
|
|
93
|
+
if (cost[key] > row.cost[key] || cost[key] > declared[key]) {throw new Error('skin cost understated');}
|
|
94
|
+
}
|
|
105
95
|
}
|
|
106
96
|
}
|
|
107
97
|
}
|
|
98
|
+
|
|
99
|
+
export { parseSkinFile, skinLookParameters } from './skin-file.ts';
|
|
100
|
+
export { resolveSkinLookFiles } from './skin-variants.ts';
|
|
101
|
+
export { skinLookRules, validateSkinAssets };
|
package/src/format/skins.ts
CHANGED
|
@@ -1,37 +1,51 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
2
|
|
|
3
3
|
/** The look recipe for an exported skin, and its animation recipe. */
|
|
4
|
-
|
|
4
|
+
const SKIN_LOOK_RECIPE = 'platform.skin';
|
|
5
5
|
/** The animation recipe that consumes the exported skin clip parameters. */
|
|
6
|
-
|
|
6
|
+
const SKIN_CLIPS_RECIPE = 'platform.clips';
|
|
7
7
|
const hash = v.pipe(v.string(), v.regex(/^[0-9a-f]{64}$/u));
|
|
8
8
|
/** The look row's parameters. */
|
|
9
|
-
|
|
9
|
+
const SkinLookParametersSchema: v.GenericSchema<SkinLookParametersRowsInput, SkinLookParametersRows> = v.strictObject({ skin: hash, variants: v.exactOptional(hash) });
|
|
10
|
+
/** Complete variant-to-skin declarations in one ordinary content-addressed JSON file. */
|
|
11
|
+
const VARIANTS_VERSION = 1;
|
|
12
|
+
const MIN_VARIANTS = 1;
|
|
13
|
+
const MAX_VARIANTS = 64;
|
|
14
|
+
const MAX_VARIANT_LENGTH = 128;
|
|
15
|
+
const variantId = v.pipe(v.string(), v.minLength(MIN_VARIANTS), v.maxLength(MAX_VARIANT_LENGTH));
|
|
16
|
+
const variantSkins = v.pipe(v.record(variantId, hash), v.minEntries(MIN_VARIANTS), v.maxEntries(MAX_VARIANTS));
|
|
17
|
+
interface SkinVariantsFields { version: typeof VARIANTS_VERSION; skins: Record<string, string> }
|
|
18
|
+
type SkinVariants = { [Key in keyof SkinVariantsFields]: SkinVariantsFields[Key] };
|
|
19
|
+
const SkinVariantsSchema: v.GenericSchema<SkinVariants> = v.strictObject({ version: v.literal(VARIANTS_VERSION),
|
|
20
|
+
skins: variantSkins });
|
|
10
21
|
/** The animation recipe's parameters. */
|
|
11
|
-
|
|
22
|
+
const SkinClipParametersSchema: v.GenericSchema<SkinClipParametersRowsInput, SkinClipParametersRows> = v.strictObject({ attackSpan: v.optional(v.pipe(v.number(), v.finite(), v.minValue(0.05), v.maxValue(10)), 1) });
|
|
12
23
|
/** The content-addressed skin file: one export row and its binding (validated together by the SF9c parsers). */
|
|
13
|
-
|
|
24
|
+
const ShardSkinFileSchema: v.GenericSchema<ShardSkinFileRowsInput, ShardSkinFileRows> = v.strictObject({ row: v.unknown(), binding: v.unknown() });
|
|
14
25
|
|
|
15
26
|
/** A parsed skin look: the file it names and the attack span its clip was sampled with. */
|
|
16
|
-
|
|
27
|
+
interface SkinLookParameters { skin: string; variants?: string; attackSpan: number }
|
|
17
28
|
|
|
18
29
|
/** Admitted data contracts, independent of validator implementation metadata. */
|
|
19
|
-
|
|
30
|
+
type SkinLookParametersRowsInput = SkinLookParametersRows;
|
|
20
31
|
interface SkinLookParametersRowsFields {
|
|
21
32
|
skin: string;
|
|
33
|
+
variants?: string;
|
|
22
34
|
}
|
|
23
|
-
|
|
35
|
+
type SkinLookParametersRows = { [Key in keyof SkinLookParametersRowsFields]: SkinLookParametersRowsFields[Key] };
|
|
24
36
|
interface SkinClipParametersRowsInputFields {
|
|
25
37
|
attackSpan?: number | undefined;
|
|
26
38
|
}
|
|
27
|
-
|
|
39
|
+
type SkinClipParametersRowsInput = { [Key in keyof SkinClipParametersRowsInputFields]: SkinClipParametersRowsInputFields[Key] };
|
|
28
40
|
interface SkinClipParametersRowsFields {
|
|
29
41
|
attackSpan: number;
|
|
30
42
|
}
|
|
31
|
-
|
|
32
|
-
|
|
43
|
+
type SkinClipParametersRows = { [Key in keyof SkinClipParametersRowsFields]: SkinClipParametersRowsFields[Key] };
|
|
44
|
+
type ShardSkinFileRowsInput = ShardSkinFileRows;
|
|
33
45
|
interface ShardSkinFileRowsFields {
|
|
34
46
|
row: unknown;
|
|
35
47
|
binding: unknown;
|
|
36
48
|
}
|
|
37
|
-
|
|
49
|
+
type ShardSkinFileRows = { [Key in keyof ShardSkinFileRowsFields]: ShardSkinFileRowsFields[Key] };
|
|
50
|
+
|
|
51
|
+
export { SKIN_LOOK_RECIPE, SKIN_CLIPS_RECIPE, SkinLookParametersSchema, type SkinVariants, SkinVariantsSchema, SkinClipParametersSchema, ShardSkinFileSchema, type SkinLookParameters, type SkinLookParametersRowsInput, type SkinLookParametersRows, type SkinClipParametersRowsInput, type SkinClipParametersRows, type ShardSkinFileRowsInput, type ShardSkinFileRows };
|
|
@@ -25,6 +25,8 @@ const tuning = v.strictObject({
|
|
|
25
25
|
herdAlertRadius: nonnegative, herdBoltDelayMin: nonnegative, herdBoltDelayMax: nonnegative, impactSpook: nonnegative, impactAlert: nonnegative,
|
|
26
26
|
stalk: v.exactOptional(stalk),
|
|
27
27
|
});
|
|
28
|
+
/** Existing hunt numbers shared by the additive species temperament layer. */
|
|
29
|
+
const HuntTuningSchema: v.GenericSchema<NonNullable<SpeciesData['tuning']>> = tuning;
|
|
28
30
|
const optionalTuning = v.strictObject({
|
|
29
31
|
hp: v.exactOptional(nonnegative), sightRange: v.exactOptional(nonnegative), sightRangeGraze: v.exactOptional(nonnegative), sightCone: v.exactOptional(nonnegative), hearStill: v.exactOptional(nonnegative),
|
|
30
32
|
hearCrouch: v.exactOptional(nonnegative), hearWalk: v.exactOptional(nonnegative), hearSprint: v.exactOptional(nonnegative), noticeRate: v.exactOptional(nonnegative), forgetRate: v.exactOptional(nonnegative),
|
|
@@ -38,7 +40,7 @@ const flight = v.strictObject({ altitude: finite, above: v.exactOptional(v.pickl
|
|
|
38
40
|
climbRate: positive, diveRate: positive, lockRange: v.exactOptional(positive),
|
|
39
41
|
bank: v.exactOptional(v.pipe(positive, v.check(n => n < Math.PI / 2, 'bank below pi/2'))) });
|
|
40
42
|
/** Strict species data, with bounded ordered variants and no native callback fields. */
|
|
41
|
-
|
|
43
|
+
const SpeciesSchema: v.StrictObjectSchema<{ readonly id: v.GenericSchema<SpeciesDataInput['id'], SpeciesData['id']>; readonly kind: v.GenericSchema<SpeciesDataInput['kind'], SpeciesData['kind']>; readonly label: v.GenericSchema<SpeciesDataInput['label'], SpeciesData['label']>; readonly variants: v.ArraySchema<v.StrictObjectSchema<{ readonly id: v.GenericSchema<SpeciesVariantDataInput['id'], SpeciesVariantData['id']>; readonly label: v.GenericSchema<SpeciesVariantDataInput['label'], SpeciesVariantData['label']>; readonly weight: v.GenericSchema<SpeciesVariantDataInput['weight'], SpeciesVariantData['weight']>; readonly rarity: v.GenericSchema<SpeciesVariantDataInput['rarity'], SpeciesVariantData['rarity']>; readonly scale: v.GenericSchema<SpeciesVariantDataInput['scale'], SpeciesVariantData['scale']>; readonly hp: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesVariantDataInput['hp'], undefined>, Exclude<SpeciesVariantData['hp'], undefined>>, undefined>; readonly mods: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesVariantDataInput['mods'], undefined>, Exclude<SpeciesVariantData['mods'], undefined>>, undefined>; }, undefined>, undefined>; readonly spawnOnly: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['spawnOnly'], undefined>, Exclude<SpeciesData['spawnOnly'], undefined>>, undefined>; readonly aggressive: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['aggressive'], undefined>, Exclude<SpeciesData['aggressive'], undefined>>, undefined>; readonly walkSpeed: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['walkSpeed'], undefined>, Exclude<SpeciesData['walkSpeed'], undefined>>, undefined>; readonly chargeSpeed: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['chargeSpeed'], undefined>, Exclude<SpeciesData['chargeSpeed'], undefined>>, undefined>; readonly chargeDamage: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['chargeDamage'], undefined>, Exclude<SpeciesData['chargeDamage'], undefined>>, undefined>; readonly chargeWindup: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['chargeWindup'], undefined>, Exclude<SpeciesData['chargeWindup'], undefined>>, undefined>; readonly ringRadius: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['ringRadius'], undefined>, Exclude<SpeciesData['ringRadius'], undefined>>, undefined>; readonly trampleRadius: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['trampleRadius'], undefined>, Exclude<SpeciesData['trampleRadius'], undefined>>, undefined>; readonly tuning: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['tuning'], undefined>, Exclude<SpeciesData['tuning'], undefined>>, undefined>; readonly sounds: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['sounds'], undefined>, Exclude<SpeciesData['sounds'], undefined>>, undefined>; readonly tick: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['tick'], undefined>, Exclude<SpeciesData['tick'], undefined>>, undefined>; readonly corpseFade: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['corpseFade'], undefined>, Exclude<SpeciesData['corpseFade'], undefined>>, undefined>; readonly blood: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['blood'], undefined>, Exclude<SpeciesData['blood'], undefined>>, undefined>; readonly flight: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['flight'], undefined>, Exclude<SpeciesData['flight'], undefined>>, undefined>; readonly lockable: v.ExactOptionalSchema<v.GenericSchema<Exclude<SpeciesDataInput['lockable'], undefined>, Exclude<SpeciesData['lockable'], undefined>>, undefined>; }, undefined> = v.strictObject({
|
|
42
44
|
id, kind: id, label: text, variants: v.pipe(v.array(variant), v.minLength(1), v.maxLength(64)),
|
|
43
45
|
spawnOnly: v.exactOptional(v.pipe(v.array(variant), v.maxLength(64))), aggressive: v.exactOptional(v.boolean()),
|
|
44
46
|
walkSpeed: v.exactOptional(nonnegative), chargeSpeed: v.exactOptional(nonnegative), chargeDamage: v.exactOptional(nonnegative),
|
|
@@ -51,9 +53,9 @@ export const SpeciesSchema: v.StrictObjectSchema<{ readonly id: v.GenericSchema<
|
|
|
51
53
|
|
|
52
54
|
/** Callback-free gameplay metadata; rendering and policy ownership are admitted separately. */
|
|
53
55
|
|
|
54
|
-
|
|
56
|
+
function readSpecies(input: unknown): SpeciesData { return v.parse(SpeciesSchema, input); }
|
|
55
57
|
/** One existing SpeciesBrains owner receives these admitted policy/body rows and strike definitions. */
|
|
56
|
-
|
|
58
|
+
const SpeciesProgramSchema: v.GenericSchema<SpeciesProgramDataInput, SpeciesProgramData> = v.pipe(v.unknown(), v.check(isJsonData, 'Species program must be plain JSON'), v.strictObject({
|
|
57
59
|
species: v.pipe(v.array(v.strictObject({ ...SpeciesSchema.entries, brain: v.exactOptional(SpeciesBrainSchema),
|
|
58
60
|
body: v.exactOptional(CreatureBodyRecipeSchema) })), v.maxLength(256)),
|
|
59
61
|
strikes: v.pipe(v.array(CreatureStrikeSchema), v.maxLength(256)),
|
|
@@ -61,12 +63,12 @@ export const SpeciesProgramSchema: v.GenericSchema<SpeciesProgramDataInput, Spec
|
|
|
61
63
|
}), v.check(value => new Set(value.species.map(row => row.kind)).size === value.species.length
|
|
62
64
|
&& new Set(value.strikes.map(row => row.id)).size === value.strikes.length, 'Unique program kinds and strikes'));
|
|
63
65
|
|
|
64
|
-
|
|
66
|
+
function readSpeciesProgram(input: unknown): SpeciesProgramData { return v.parse(SpeciesProgramSchema, input); }
|
|
65
67
|
|
|
66
68
|
const names = v.pipe(v.array(id), v.maxLength(64));
|
|
67
69
|
const tag = v.custom<`${string}.${string}`>(value => typeof value === 'string' && value.length <= 128 && /^[a-z][a-zA-Z0-9.-]*\.[a-zA-Z0-9.-]+$/u.test(value));
|
|
68
70
|
/** Settings for the existing native hunt and continuation owners; no callbacks or replacement clock. */
|
|
69
|
-
|
|
71
|
+
const NativeHuntSchema: v.GenericSchema<NativeHuntRowsInput, NativeHuntRows> = v.strictObject({
|
|
70
72
|
limit: v.pipe(positive, v.integer(), v.maxValue(1024)), player: v.picklist(['host', 'origin']),
|
|
71
73
|
fight: v.strictObject({ telegraphed: v.exactOptional(v.boolean()), attackers: v.exactOptional(v.pipe(positive, v.integer(), v.maxValue(1024))),
|
|
72
74
|
maxHitDamage: v.exactOptional(nonnegative), capExempt: v.exactOptional(names),
|
|
@@ -77,21 +79,24 @@ export const NativeHuntSchema: v.GenericSchema<NativeHuntRowsInput, NativeHuntRo
|
|
|
77
79
|
});
|
|
78
80
|
|
|
79
81
|
/** Page and native registration order is authored explicitly; empty sides install no rows. */
|
|
80
|
-
|
|
82
|
+
const SpeciesProgramsSchema: v.GenericSchema<SpeciesProgramsInput, SpeciesPrograms> = v.pipe(v.unknown(), v.check(isJsonData, 'Species programs must be plain JSON'),
|
|
81
83
|
v.strictObject({ page: v.pipe(v.array(SpeciesSchema), v.maxLength(256)), native: v.pipe(v.array(SpeciesSchema), v.maxLength(256)), program: v.exactOptional(SpeciesProgramSchema),
|
|
82
84
|
spawns: v.exactOptional(SpawnTablesSchema), hunt: v.exactOptional(NativeHuntSchema) }),
|
|
83
85
|
v.check(value => [value.page, value.native].every(rows => new Set(rows.map(row => row.kind)).size === rows.length), 'Unique species kinds per owner'));
|
|
84
86
|
|
|
85
|
-
|
|
87
|
+
function readSpeciesPrograms(input: unknown): SpeciesPrograms { return v.parse(SpeciesProgramsSchema, input); }
|
|
86
88
|
|
|
87
89
|
/** Validated species metadata independent of validator implementation types. */
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
90
|
+
type SpeciesVariantDataInput = SpeciesVariantData;
|
|
91
|
+
interface SpeciesVariantData { id: string; label: string; weight: number; rarity: 'common' | 'uncommon' | 'rare' | 'legendary'; scale: [number, number]; hp?: number; mods?: { speed?: number; chargeDist?: number; damageTaken?: number; chargeDamage?: number; relentless?: boolean; }; }
|
|
92
|
+
interface SpeciesDataInput { id: string; kind: string; label: string; variants: (SpeciesVariantDataInput)[]; spawnOnly?: (SpeciesVariantDataInput)[]; aggressive?: boolean; walkSpeed?: number; chargeSpeed?: number; chargeDamage?: number; chargeWindup?: number; ringRadius?: number; trampleRadius?: number; tuning?: { hp: number; sightRange: number; sightRangeGraze: number; sightCone: number; hearStill: number; hearCrouch: number; hearWalk: number; hearSprint: number; noticeRate: number; forgetRate: number; alertAt: number; boltAt: number; freezeMin: number; freezeMax: number; relaxAfter: number; panicDist: number; runSpeed: number; trotSpeed: number; fleeMinTime: number; fleeUntil: number; fleeUntilMax: number; fleeMaxTime: number; lookBack: number; waryTime: number; waryBoost: number; herdAlertRadius: number; herdBoltDelayMin: number; herdBoltDelayMax: number; impactSpook: number; impactAlert: number; stalk?: { detect: number; speed: number; giveUp: number; rechargeCd: number; huffMin: number; huffMax: number; roar: string; fleeBelowHp: number; fleeChance: number; }; }; sounds?: { call: string; hurt: string; callVariants?: (string)[]; callEvery?: [number, number]; }; tick?: 'ai' | 'always'; corpseFade?: number; blood?: boolean; flight?: { altitude: number; above?: 'ground' | 'world'; climbRate: number; diveRate: number; lockRange?: number; bank?: number; }; lockable?: boolean; }
|
|
93
|
+
interface SpeciesData { id: string; kind: string; label: string; variants: (SpeciesVariantData)[]; spawnOnly?: (SpeciesVariantData)[]; aggressive?: boolean; walkSpeed?: number; chargeSpeed?: number; chargeDamage?: number; chargeWindup?: number; ringRadius?: number; trampleRadius?: number; tuning?: { hp: number; sightRange: number; sightRangeGraze: number; sightCone: number; hearStill: number; hearCrouch: number; hearWalk: number; hearSprint: number; noticeRate: number; forgetRate: number; alertAt: number; boltAt: number; freezeMin: number; freezeMax: number; relaxAfter: number; panicDist: number; runSpeed: number; trotSpeed: number; fleeMinTime: number; fleeUntil: number; fleeUntilMax: number; fleeMaxTime: number; lookBack: number; waryTime: number; waryBoost: number; herdAlertRadius: number; herdBoltDelayMin: number; herdBoltDelayMax: number; impactSpook: number; impactAlert: number; stalk?: { detect: number; speed: number; giveUp: number; rechargeCd: number; huffMin: number; huffMax: number; roar: string; fleeBelowHp: number; fleeChance: number; }; }; sounds?: { call: string; hurt: string; callVariants?: (string)[]; callEvery?: [number, number]; }; tick?: 'ai' | 'always'; corpseFade?: number; blood?: boolean; flight?: { altitude: number; above?: 'ground' | 'world'; climbRate: number; diveRate: number; lockRange?: number; bank?: number; }; lockable?: boolean; }
|
|
94
|
+
type SpeciesProgramDataInput = unknown;
|
|
95
|
+
interface SpeciesProgramData { species: ({ brain?: v.InferOutput<typeof SpeciesBrainSchema>; body?: v.InferOutput<typeof CreatureBodyRecipeSchema>; } & SpeciesData)[]; strikes: (v.InferOutput<typeof CreatureStrikeSchema>)[]; modules?: Record<string, string>; }
|
|
96
|
+
type NativeHuntRowsInput = NativeHuntRows;
|
|
97
|
+
interface NativeHuntRows { limit: number; player: 'host' | 'origin'; fight: { telegraphed?: boolean; attackers?: number; maxHitDamage?: number; capExempt?: (string)[]; input?: { bufferMs: number; coyoteMs: number; }; }; tuning?: Record<string, { hp?: number; sightRange?: number; sightRangeGraze?: number; sightCone?: number; hearStill?: number; hearCrouch?: number; hearWalk?: number; hearSprint?: number; noticeRate?: number; forgetRate?: number; alertAt?: number; boltAt?: number; freezeMin?: number; freezeMax?: number; relaxAfter?: number; panicDist?: number; runSpeed?: number; trotSpeed?: number; fleeMinTime?: number; fleeUntil?: number; fleeUntilMax?: number; fleeMaxTime?: number; lookBack?: number; waryTime?: number; waryBoost?: number; herdAlertRadius?: number; herdBoltDelayMin?: number; herdBoltDelayMax?: number; impactSpook?: number; impactAlert?: number; stalk?: { detect: number; speed: number; giveUp: number; rechargeCd: number; huffMin: number; huffMax: number; roar: string; fleeBelowHp: number; fleeChance: number; }; }>; bands: { states: (string)[]; scripted?: boolean; legacyKinds: (string)[]; }; hit: { namespace: string; tags: (`${string}.${string}`)[]; }; memoryFields?: (string)[]; }
|
|
98
|
+
type SpeciesProgramsInput = unknown;
|
|
99
|
+
interface SpeciesPrograms { page: (SpeciesData)[]; native: (SpeciesData)[]; program?: SpeciesProgramData; spawns?: v.InferOutput<typeof SpawnTablesSchema>; hunt?: NativeHuntRows; }
|
|
100
|
+
|
|
101
|
+
export { HuntTuningSchema, SpeciesSchema, readSpecies, SpeciesProgramSchema, readSpeciesProgram, NativeHuntSchema, SpeciesProgramsSchema, readSpeciesPrograms };
|
|
102
|
+
export type { SpeciesVariantDataInput, SpeciesVariantData, SpeciesDataInput, SpeciesData, SpeciesProgramDataInput, SpeciesProgramData, NativeHuntRowsInput, NativeHuntRows, SpeciesProgramsInput, SpeciesPrograms };
|
package/src/format/view-draws.ts
CHANGED
|
@@ -30,6 +30,20 @@ interface ViewTile {
|
|
|
30
30
|
const VIEW_DRAWS: { readonly phone: number; readonly desktop: number } =
|
|
31
31
|
Object.freeze({ desktop: DESKTOP_VIEW, phone: PHONE_VIEW })
|
|
32
32
|
|
|
33
|
+
/** Desktop's fine-tile triangles: Mossgate's fullest tile (364,625) holds the 60 fps cap on desktop. */
|
|
34
|
+
const DESKTOP_TILE_TRIANGLES = 400_000
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* SHARD-SOURCE AP9b: one fine (L0) tile's triangles per tier. The phone's is
|
|
38
|
+
* `CONTENT_CAPS.l0.triangles`; desktop's is raised under J338 (look first).
|
|
39
|
+
* Both are reported, not enforced: the sdk's budget table reads them.
|
|
40
|
+
*/
|
|
41
|
+
const TILE_TRIANGLES: { readonly phone: number; readonly desktop: number } =
|
|
42
|
+
Object.freeze({
|
|
43
|
+
desktop: DESKTOP_TILE_TRIANGLES,
|
|
44
|
+
phone: CONTENT_CAPS.l0.triangles,
|
|
45
|
+
})
|
|
46
|
+
|
|
33
47
|
function centre(tile: ViewTile, axis: number): number {
|
|
34
48
|
const box = tile.drawBounds ?? tile.bounds
|
|
35
49
|
return ((box.min[axis] ?? NONE) + (box.max[axis] ?? NONE)) / HALF
|
|
@@ -70,4 +84,4 @@ function viewDraws(tiles: readonly ViewTile[], from: ViewTile): number {
|
|
|
70
84
|
}
|
|
71
85
|
|
|
72
86
|
export type { ViewTile }
|
|
73
|
-
export { VIEW_DRAWS, viewDraws }
|
|
87
|
+
export { TILE_TRIANGLES, VIEW_DRAWS, viewDraws }
|