@wildshard/shard-format 0.9.0 → 0.10.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 +2 -1
- package/src/format/look-light.ts +23 -11
- package/src/format/look-swing.ts +96 -0
- package/src/format/materialFamilies.ts +11 -7
- package/src/format/scene-render.ts +12 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wildshard/shard-format",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.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": {
|
|
@@ -249,6 +249,7 @@
|
|
|
249
249
|
"./postStack": "./src/format/postStack.ts",
|
|
250
250
|
"./look-details": "./src/format/look-details.ts",
|
|
251
251
|
"./look-light": "./src/format/look-light.ts",
|
|
252
|
+
"./look-swing": "./src/format/look-swing.ts",
|
|
252
253
|
"./look-render": "./src/format/look-render.ts",
|
|
253
254
|
"./pool-surface": "./src/format/pool-surface.ts",
|
|
254
255
|
"./practiceCourseRows": "./src/format/practiceCourseRows.ts",
|
package/src/format/look-light.ts
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
* `at` in linear `colour` × `intensity` (candela), out to `distance` metres with physical (2) decay, no shadow.
|
|
14
14
|
* - `bounce` (B2): a warm fill from the ground: one shadowless directional light from the anti-sun heading, lifted
|
|
15
15
|
* by `lift` (0 level, 1 straight up), in linear `colour` × `intensity`.
|
|
16
|
+
* - `swings` (SHARD-SOURCE SS8b): hanging bodies a lamp's `swing` names, so its light swings too (`look-swing.ts`).
|
|
16
17
|
* - `environment` (B2): sky-derived ambient: an environment filtered once from the look's own sky (its keys' zenith
|
|
17
18
|
* and horizon) over a `ground` colour (linear), lighting every PBR surface at `intensity`.
|
|
18
19
|
*
|
|
@@ -27,6 +28,7 @@
|
|
|
27
28
|
*/
|
|
28
29
|
import {
|
|
29
30
|
array,
|
|
31
|
+
check,
|
|
30
32
|
exactOptional,
|
|
31
33
|
finite,
|
|
32
34
|
maxLength,
|
|
@@ -49,6 +51,7 @@ import {
|
|
|
49
51
|
lampFlicker,
|
|
50
52
|
lampHalo,
|
|
51
53
|
} from './look-render.ts'
|
|
54
|
+
import { LookSwingsSchema, swingNumber, swingsDeclared } from './look-swing.ts'
|
|
52
55
|
|
|
53
56
|
import type {
|
|
54
57
|
LookLampFlicker,
|
|
@@ -56,6 +59,7 @@ import type {
|
|
|
56
59
|
LookMotes,
|
|
57
60
|
LookShadow,
|
|
58
61
|
} from './look-render.ts'
|
|
62
|
+
import type { LookSwing } from './look-swing.ts'
|
|
59
63
|
import type { GenericSchema } from 'valibot'
|
|
60
64
|
|
|
61
65
|
type Rgb = [number, number, number]
|
|
@@ -130,6 +134,8 @@ interface LookLamp {
|
|
|
130
134
|
decay?: number
|
|
131
135
|
halo?: LookLampHalo
|
|
132
136
|
flicker?: LookLampFlicker
|
|
137
|
+
/** SS8b: the number of the `swings` row it hangs from */
|
|
138
|
+
swing?: number
|
|
133
139
|
}
|
|
134
140
|
/** A warm fill from the ground: a shadowless directional light from the anti-sun heading, lifted by `lift`. */
|
|
135
141
|
interface LookBounce {
|
|
@@ -149,6 +155,7 @@ interface LookLight {
|
|
|
149
155
|
heightFog?: LookHeightFog
|
|
150
156
|
pools?: LookPools
|
|
151
157
|
lamps?: LookLamp[]
|
|
158
|
+
swings?: LookSwing[]
|
|
152
159
|
bounce?: LookBounce
|
|
153
160
|
environment?: LookEnvironment
|
|
154
161
|
shadow?: LookShadow
|
|
@@ -215,6 +222,7 @@ const LookLampSchema: GenericSchema<LookLamp, LookLamp> = strictObject({
|
|
|
215
222
|
decay: lampDecay,
|
|
216
223
|
halo: lampHalo,
|
|
217
224
|
flicker: lampFlicker,
|
|
225
|
+
swing: exactOptional(swingNumber),
|
|
218
226
|
})
|
|
219
227
|
const LookLampsSchema: GenericSchema<LookLamp[], LookLamp[]> = pipe(
|
|
220
228
|
array(LookLampSchema),
|
|
@@ -232,17 +240,21 @@ const LookEnvironmentSchema: GenericSchema<LookEnvironment, LookEnvironment> =
|
|
|
232
240
|
ground: colour,
|
|
233
241
|
})
|
|
234
242
|
/** `look.light`: the optional light and post settings. */
|
|
235
|
-
const LookLightSchema: GenericSchema<LookLight, LookLight> =
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
243
|
+
const LookLightSchema: GenericSchema<LookLight, LookLight> = pipe(
|
|
244
|
+
strictObject({
|
|
245
|
+
ao: exactOptional(LookAoSchema),
|
|
246
|
+
rim: exactOptional(LookRimSchema),
|
|
247
|
+
heightFog: exactOptional(LookHeightFogSchema),
|
|
248
|
+
pools: exactOptional(LookPoolsSchema),
|
|
249
|
+
lamps: exactOptional(LookLampsSchema),
|
|
250
|
+
swings: exactOptional(LookSwingsSchema),
|
|
251
|
+
bounce: exactOptional(LookBounceSchema),
|
|
252
|
+
environment: exactOptional(LookEnvironmentSchema),
|
|
253
|
+
shadow: exactOptional(LookShadowSchema),
|
|
254
|
+
motes: exactOptional(LookMotesSchema),
|
|
255
|
+
}),
|
|
256
|
+
check<LookLight, string>(swingsDeclared, 'A lamp on an undeclared swing'),
|
|
257
|
+
)
|
|
246
258
|
/** `look.grade.tone`: absent is AgX, as before. */
|
|
247
259
|
const LookToneSchema: GenericSchema<LookTone, LookTone> = picklist([
|
|
248
260
|
'agx',
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `look.light.swings` (meta SHARD-SOURCE SS8b): bodies that hang and swing (a lantern on its rope, a sign, a banner), at
|
|
3
|
+
* most `LOOK_SWINGS_MAX`. Each hangs from `pivot` with its body `length` metres below, swings at about `rate` hertz, leans
|
|
4
|
+
* up to `amount` radians in a gust, and swings when a player or creature comes within `reach` metres of its body (0
|
|
5
|
+
* never). A surface's `_SWING` channel (`scene-render.ts`) and a lamp's `swing` name a row by number, so the lamp's light
|
|
6
|
+
* turns with its lantern round the same pivot.
|
|
7
|
+
*
|
|
8
|
+
* Plain data and checks, no three.js.
|
|
9
|
+
*/
|
|
10
|
+
import {
|
|
11
|
+
array,
|
|
12
|
+
finite,
|
|
13
|
+
integer,
|
|
14
|
+
maxLength,
|
|
15
|
+
maxValue,
|
|
16
|
+
minLength,
|
|
17
|
+
minValue,
|
|
18
|
+
number,
|
|
19
|
+
pipe,
|
|
20
|
+
strictObject,
|
|
21
|
+
tuple,
|
|
22
|
+
} from 'valibot'
|
|
23
|
+
|
|
24
|
+
import type { GenericSchema } from 'valibot'
|
|
25
|
+
|
|
26
|
+
type Point = [number, number, number]
|
|
27
|
+
|
|
28
|
+
/** At most this many swings in one look (one uniform array on every swinging draw, phones included). */
|
|
29
|
+
const LOOK_SWINGS_MAX = 32
|
|
30
|
+
const NONE = 0
|
|
31
|
+
const ONE = 1
|
|
32
|
+
const LENGTH_MIN = 0.05
|
|
33
|
+
const LENGTH_MAX = 10
|
|
34
|
+
const RATE_MIN = 0.05
|
|
35
|
+
const RATE_MAX = 4
|
|
36
|
+
const AMOUNT_MAX = 0.6
|
|
37
|
+
const REACH_MAX = 3
|
|
38
|
+
|
|
39
|
+
/** A hanging body: its pivot, body length, swing rate (hertz), gust lean (radians) and bump reach (metres). */
|
|
40
|
+
interface LookSwing {
|
|
41
|
+
pivot: Point
|
|
42
|
+
length: number
|
|
43
|
+
rate: number
|
|
44
|
+
amount: number
|
|
45
|
+
reach: number
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const real = pipe(number(), finite())
|
|
49
|
+
const range = (low: number, high: number): GenericSchema<number, number> =>
|
|
50
|
+
pipe(real, minValue(low), maxValue(high))
|
|
51
|
+
|
|
52
|
+
const LookSwingSchema: GenericSchema<LookSwing, LookSwing> = strictObject({
|
|
53
|
+
pivot: tuple([real, real, real]),
|
|
54
|
+
length: range(LENGTH_MIN, LENGTH_MAX),
|
|
55
|
+
rate: range(RATE_MIN, RATE_MAX),
|
|
56
|
+
amount: range(NONE, AMOUNT_MAX),
|
|
57
|
+
reach: range(NONE, REACH_MAX),
|
|
58
|
+
})
|
|
59
|
+
const LookSwingsSchema: GenericSchema<LookSwing[], LookSwing[]> = pipe(
|
|
60
|
+
array(LookSwingSchema),
|
|
61
|
+
minLength(ONE),
|
|
62
|
+
maxLength(LOOK_SWINGS_MAX),
|
|
63
|
+
)
|
|
64
|
+
/** A lamp's `swing`: the number of the row it hangs from. */
|
|
65
|
+
const swingNumber: GenericSchema<number, number> = pipe(
|
|
66
|
+
real,
|
|
67
|
+
integer(),
|
|
68
|
+
minValue(NONE),
|
|
69
|
+
maxValue(LOOK_SWINGS_MAX - ONE),
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
/** What `swingsDeclared` reads of a `look.light`. */
|
|
73
|
+
interface SwingRefs {
|
|
74
|
+
readonly lamps?: readonly { readonly swing?: number }[] | undefined
|
|
75
|
+
readonly swings?: readonly unknown[] | undefined
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Every lamp's `swing` names a declared swing. */
|
|
79
|
+
function swingsDeclared(light: SwingRefs): boolean {
|
|
80
|
+
const declared = light.swings?.length ?? NONE
|
|
81
|
+
for (const lamp of light.lamps ?? []) {
|
|
82
|
+
if (lamp.swing !== undefined && lamp.swing >= declared) {
|
|
83
|
+
return false
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return true
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export {
|
|
90
|
+
LOOK_SWINGS_MAX,
|
|
91
|
+
LookSwingSchema,
|
|
92
|
+
LookSwingsSchema,
|
|
93
|
+
swingNumber,
|
|
94
|
+
swingsDeclared,
|
|
95
|
+
}
|
|
96
|
+
export type { LookSwing, SwingRefs }
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
import { detailLayer } from './detail-layer.ts';
|
|
19
19
|
import type { DetailLayer } from './detail-layer.ts';
|
|
20
20
|
import { pbrEmissive, pbrEmissiveIntensity } from './pbr-emissive.ts';
|
|
21
|
-
import { emissiveCard, emissiveMotion, surfaceBlend, surfaceDepthOffset, surfaceOpacity, surfaceSway, surfaceUvScroll } from './scene-render.ts';
|
|
21
|
+
import { emissiveCard, emissiveMotion, surfaceBlend, surfaceDepthOffset, surfaceOpacity, surfaceSway, surfaceSwing, surfaceUvScroll } from './scene-render.ts';
|
|
22
22
|
import type { CardMotion, SurfaceSway } from './scene-render.ts';
|
|
23
23
|
import * as v from 'valibot';
|
|
24
24
|
|
|
@@ -212,7 +212,7 @@ export function measureUv(role: MeasureRole, u: number, up: number, w: number, h
|
|
|
212
212
|
}
|
|
213
213
|
|
|
214
214
|
/** One PBR surface: metal / rough with colour, normal and packed ORM maps (occlusion r, roughness g, metalness b). */
|
|
215
|
-
export const PbrMaterialSchema: v.StrictObjectSchema<{ readonly family: v.GenericSchema<PbrMaterialParamsInput['family'], PbrMaterialParams['family']>; readonly colour: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['colour'], undefined>, PbrMaterialParams['colour']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['colour'], undefined>>>; readonly roughness: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['roughness'], undefined>, PbrMaterialParams['roughness']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['roughness'], undefined>>>; readonly metalness: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['metalness'], undefined>, PbrMaterialParams['metalness']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['metalness'], undefined>>>; readonly maps: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['maps'], undefined>, PbrMaterialParams['maps']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['maps'], undefined>>>; readonly normalScale: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['normalScale'], undefined>, PbrMaterialParams['normalScale']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['normalScale'], undefined>>>; readonly occlusion: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['occlusion'], undefined>, PbrMaterialParams['occlusion']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['occlusion'], undefined>>>; readonly envStrength: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['envStrength'], undefined>, PbrMaterialParams['envStrength']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['envStrength'], undefined>>>; readonly vertexColours: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['vertexColours'], undefined>, PbrMaterialParams['vertexColours']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['vertexColours'], undefined>>>; readonly faceted: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['faceted'], undefined>, PbrMaterialParams['faceted']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['faceted'], undefined>>>; readonly doubleSided: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['doubleSided'], undefined>, PbrMaterialParams['doubleSided']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['doubleSided'], undefined>>>; readonly alphaCutoff: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['alphaCutoff'], undefined>, PbrMaterialParams['alphaCutoff']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['alphaCutoff'], undefined>>>; readonly ground: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['ground'], undefined>, PbrMaterialParams['ground']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['ground'], undefined>>>; readonly measure: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['measure'], undefined>, PbrMaterialParams['measure']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['measure'], undefined>>>; readonly detail: typeof detailLayer; readonly emissive: typeof pbrEmissive; readonly emissiveIntensity: typeof pbrEmissiveIntensity; readonly blend: typeof surfaceBlend; readonly opacity: typeof surfaceOpacity; readonly depthOffset: typeof surfaceDepthOffset; readonly sway: typeof surfaceSway; readonly uvScroll: typeof surfaceUvScroll; }, undefined> = v.strictObject({
|
|
215
|
+
export const PbrMaterialSchema: v.StrictObjectSchema<{ readonly family: v.GenericSchema<PbrMaterialParamsInput['family'], PbrMaterialParams['family']>; readonly colour: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['colour'], undefined>, PbrMaterialParams['colour']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['colour'], undefined>>>; readonly roughness: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['roughness'], undefined>, PbrMaterialParams['roughness']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['roughness'], undefined>>>; readonly metalness: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['metalness'], undefined>, PbrMaterialParams['metalness']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['metalness'], undefined>>>; readonly maps: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['maps'], undefined>, PbrMaterialParams['maps']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['maps'], undefined>>>; readonly normalScale: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['normalScale'], undefined>, PbrMaterialParams['normalScale']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['normalScale'], undefined>>>; readonly occlusion: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['occlusion'], undefined>, PbrMaterialParams['occlusion']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['occlusion'], undefined>>>; readonly envStrength: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['envStrength'], undefined>, PbrMaterialParams['envStrength']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['envStrength'], undefined>>>; readonly vertexColours: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['vertexColours'], undefined>, PbrMaterialParams['vertexColours']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['vertexColours'], undefined>>>; readonly faceted: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['faceted'], undefined>, PbrMaterialParams['faceted']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['faceted'], undefined>>>; readonly doubleSided: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['doubleSided'], undefined>, PbrMaterialParams['doubleSided']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['doubleSided'], undefined>>>; readonly alphaCutoff: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['alphaCutoff'], undefined>, PbrMaterialParams['alphaCutoff']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['alphaCutoff'], undefined>>>; readonly ground: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['ground'], undefined>, PbrMaterialParams['ground']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['ground'], undefined>>>; readonly measure: v.OptionalSchema<v.GenericSchema<Exclude<PbrMaterialParamsInput['measure'], undefined>, PbrMaterialParams['measure']>, MaterialSchemaDefault<Exclude<PbrMaterialParamsInput['measure'], undefined>>>; readonly detail: typeof detailLayer; readonly emissive: typeof pbrEmissive; readonly emissiveIntensity: typeof pbrEmissiveIntensity; readonly blend: typeof surfaceBlend; readonly opacity: typeof surfaceOpacity; readonly depthOffset: typeof surfaceDepthOffset; readonly sway: typeof surfaceSway; readonly uvScroll: typeof surfaceUvScroll; readonly swing: typeof surfaceSwing; }, undefined> = v.strictObject({
|
|
216
216
|
family: v.literal('pbr'),
|
|
217
217
|
/** sRGB, multiplies the colour map */
|
|
218
218
|
colour: v.optional(srgb, [1, 1, 1]),
|
|
@@ -252,6 +252,8 @@ export const PbrMaterialSchema: v.StrictObjectSchema<{ readonly family: v.Generi
|
|
|
252
252
|
sway: surfaceSway,
|
|
253
253
|
/** AP12: the colour map's uv scroll (units a second); absent = still */
|
|
254
254
|
uvScroll: surfaceUvScroll,
|
|
255
|
+
/** SS8b: a hanging body, its swing per vertex in the `_SWING` channel; absent = rigid */
|
|
256
|
+
swing: surfaceSwing,
|
|
255
257
|
});
|
|
256
258
|
/** A PBR material entry with every default filled. */
|
|
257
259
|
|
|
@@ -462,7 +464,7 @@ export const SkyDomeSchema: v.GenericSchema<SkyDomeParamsInput, SkyDomeParams> =
|
|
|
462
464
|
* One emissive surface: unlit light. `colour` × `intensity` (HDR) × the vertex colours × an optional map, flickering by a
|
|
463
465
|
* seed, fogged at a share of the fog. With `tube` it draws a neon glyph from a distance field; with `sky`, a sky dome.
|
|
464
466
|
*/
|
|
465
|
-
export const EmissiveMaterialSchema: v.StrictObjectSchema<{ readonly family: v.GenericSchema<EmissiveMaterialParamsInput['family'], EmissiveMaterialParams['family']>; readonly colour: v.OptionalSchema<v.GenericSchema<Exclude<EmissiveMaterialParamsInput['colour'], undefined>, EmissiveMaterialParams['colour']>, MaterialSchemaDefault<Exclude<EmissiveMaterialParamsInput['colour'], undefined>>>; readonly intensity: v.OptionalSchema<v.GenericSchema<Exclude<EmissiveMaterialParamsInput['intensity'], undefined>, EmissiveMaterialParams['intensity']>, MaterialSchemaDefault<Exclude<EmissiveMaterialParamsInput['intensity'], undefined>>>; readonly vertexColours: v.OptionalSchema<v.GenericSchema<Exclude<EmissiveMaterialParamsInput['vertexColours'], undefined>, EmissiveMaterialParams['vertexColours']>, MaterialSchemaDefault<Exclude<EmissiveMaterialParamsInput['vertexColours'], undefined>>>; readonly map: v.OptionalSchema<v.GenericSchema<Exclude<EmissiveMaterialParamsInput['map'], undefined>, EmissiveMaterialParams['map']>, MaterialSchemaDefault<Exclude<EmissiveMaterialParamsInput['map'], undefined>>>; readonly blend: v.OptionalSchema<v.GenericSchema<Exclude<EmissiveMaterialParamsInput['blend'], undefined>, EmissiveMaterialParams['blend']>, MaterialSchemaDefault<Exclude<EmissiveMaterialParamsInput['blend'], undefined>>>; readonly doubleSided: v.OptionalSchema<v.GenericSchema<Exclude<EmissiveMaterialParamsInput['doubleSided'], undefined>, EmissiveMaterialParams['doubleSided']>, MaterialSchemaDefault<Exclude<EmissiveMaterialParamsInput['doubleSided'], undefined>>>; readonly fog: v.OptionalSchema<v.GenericSchema<Exclude<EmissiveMaterialParamsInput['fog'], undefined>, EmissiveMaterialParams['fog']>, MaterialSchemaDefault<Exclude<EmissiveMaterialParamsInput['fog'], undefined>>>; readonly flicker: v.OptionalSchema<v.GenericSchema<Exclude<EmissiveMaterialParamsInput['flicker'], undefined>, EmissiveMaterialParams['flicker']>, MaterialSchemaDefault<Exclude<EmissiveMaterialParamsInput['flicker'], undefined>>>; readonly tube: v.OptionalSchema<v.GenericSchema<Exclude<EmissiveMaterialParamsInput['tube'], undefined>, EmissiveMaterialParams['tube']>, MaterialSchemaDefault<Exclude<EmissiveMaterialParamsInput['tube'], undefined>>>; readonly sky: v.OptionalSchema<v.GenericSchema<Exclude<EmissiveMaterialParamsInput['sky'], undefined>, EmissiveMaterialParams['sky']>, MaterialSchemaDefault<Exclude<EmissiveMaterialParamsInput['sky'], undefined>>>; readonly card: typeof emissiveCard; readonly motion: typeof emissiveMotion; }, undefined> = v.strictObject({
|
|
467
|
+
export const EmissiveMaterialSchema: v.StrictObjectSchema<{ readonly family: v.GenericSchema<EmissiveMaterialParamsInput['family'], EmissiveMaterialParams['family']>; readonly colour: v.OptionalSchema<v.GenericSchema<Exclude<EmissiveMaterialParamsInput['colour'], undefined>, EmissiveMaterialParams['colour']>, MaterialSchemaDefault<Exclude<EmissiveMaterialParamsInput['colour'], undefined>>>; readonly intensity: v.OptionalSchema<v.GenericSchema<Exclude<EmissiveMaterialParamsInput['intensity'], undefined>, EmissiveMaterialParams['intensity']>, MaterialSchemaDefault<Exclude<EmissiveMaterialParamsInput['intensity'], undefined>>>; readonly vertexColours: v.OptionalSchema<v.GenericSchema<Exclude<EmissiveMaterialParamsInput['vertexColours'], undefined>, EmissiveMaterialParams['vertexColours']>, MaterialSchemaDefault<Exclude<EmissiveMaterialParamsInput['vertexColours'], undefined>>>; readonly map: v.OptionalSchema<v.GenericSchema<Exclude<EmissiveMaterialParamsInput['map'], undefined>, EmissiveMaterialParams['map']>, MaterialSchemaDefault<Exclude<EmissiveMaterialParamsInput['map'], undefined>>>; readonly blend: v.OptionalSchema<v.GenericSchema<Exclude<EmissiveMaterialParamsInput['blend'], undefined>, EmissiveMaterialParams['blend']>, MaterialSchemaDefault<Exclude<EmissiveMaterialParamsInput['blend'], undefined>>>; readonly doubleSided: v.OptionalSchema<v.GenericSchema<Exclude<EmissiveMaterialParamsInput['doubleSided'], undefined>, EmissiveMaterialParams['doubleSided']>, MaterialSchemaDefault<Exclude<EmissiveMaterialParamsInput['doubleSided'], undefined>>>; readonly fog: v.OptionalSchema<v.GenericSchema<Exclude<EmissiveMaterialParamsInput['fog'], undefined>, EmissiveMaterialParams['fog']>, MaterialSchemaDefault<Exclude<EmissiveMaterialParamsInput['fog'], undefined>>>; readonly flicker: v.OptionalSchema<v.GenericSchema<Exclude<EmissiveMaterialParamsInput['flicker'], undefined>, EmissiveMaterialParams['flicker']>, MaterialSchemaDefault<Exclude<EmissiveMaterialParamsInput['flicker'], undefined>>>; readonly tube: v.OptionalSchema<v.GenericSchema<Exclude<EmissiveMaterialParamsInput['tube'], undefined>, EmissiveMaterialParams['tube']>, MaterialSchemaDefault<Exclude<EmissiveMaterialParamsInput['tube'], undefined>>>; readonly sky: v.OptionalSchema<v.GenericSchema<Exclude<EmissiveMaterialParamsInput['sky'], undefined>, EmissiveMaterialParams['sky']>, MaterialSchemaDefault<Exclude<EmissiveMaterialParamsInput['sky'], undefined>>>; readonly card: typeof emissiveCard; readonly motion: typeof emissiveMotion; readonly swing: typeof surfaceSwing; }, undefined> = v.strictObject({
|
|
466
468
|
family: v.literal('emissive'),
|
|
467
469
|
/** sRGB tint */
|
|
468
470
|
colour: v.optional(srgb, [1, 1, 1]),
|
|
@@ -485,6 +487,8 @@ export const EmissiveMaterialSchema: v.StrictObjectSchema<{ readonly family: v.G
|
|
|
485
487
|
card: emissiveCard,
|
|
486
488
|
/** AP12: a card's declared motion (pulse, drift, rise); absent = still */
|
|
487
489
|
motion: emissiveMotion,
|
|
490
|
+
/** SS8b: a hanging card or surface, its swing per vertex in the `_SWING` channel; absent = still */
|
|
491
|
+
swing: surfaceSwing,
|
|
488
492
|
});
|
|
489
493
|
/** An emissive material entry with every default filled. */
|
|
490
494
|
|
|
@@ -566,9 +570,9 @@ export interface GroundLayerParamsInput { wind?: [number, number] | undefined; w
|
|
|
566
570
|
export interface GroundLayerParams { wind: [number, number]; wavelength: [number, number]; lump: number; depth: [number, number]; relief: [number, number, number]; contrast: { near: number; far: number; window: [number, number]; strength: number; }; fade: [number, number]; slip: [number, number]; flat: [number, number]; patches: { floor: number; near: number; window: [number, number]; }; grain: { map: (string) | null; mean: number; glintMean: number; strength: number; }; macro: [[number, number, number], [number, number, number]]; albedo: number; streaks: { tint: [number, number, number]; amount: number; }; trail: ({ map: string; rect: [number, number, number, number]; ripples: number; tint: [number, number, number]; amount: number; }) | null; keyShadow: ({ map: string; rect: [number, number, number, number]; edge: [number, number]; floor: number; }) | null; terminator: number; crest: { band: [number, number]; gain: number; }; sheen: number; shade: { tint: [number, number, number]; gain: number; lift: [number, number, number]; amount: number; edge: number; floor: [number, number, number]; }; saturation: { flat: number; facing: number; coolTint: [number, number, number]; keep: number; }; away: { from: [number, number]; amount: number; }; pools: ({ low: [number, number, number]; high: [number, number, number]; split: number; radius: number; gain: number; source?: string; }) | null; }
|
|
567
571
|
export interface MeasureLayerParamsInput { structure?: [number, number, number] | undefined; trim?: [number, number, number] | undefined; floor?: [number, number, number] | undefined; line?: { colour: [number, number, number]; alpha: number; floorAlpha: number; width: number; } | undefined; sub?: { step: number; alpha: number; } | undefined; label?: { colour: [number, number, number]; height: number; } | undefined; lift?: number | undefined; tint?: [number, number, number]; grain?: { amount: [number, number, number]; size: number; }; grid?: [number, number, number]; }
|
|
568
572
|
export interface MeasureLayerParams { structure: [number, number, number]; trim: [number, number, number]; floor: [number, number, number]; line: { colour: [number, number, number]; alpha: number; floorAlpha: number; width: number; }; sub: { step: number; alpha: number; }; label: { colour: [number, number, number]; height: number; }; lift: number; tint?: [number, number, number]; grain?: { amount: [number, number, number]; size: number; }; grid?: [number, number, number]; }
|
|
569
|
-
export interface PbrMaterialParamsInput { family: 'pbr'; colour?: [number, number, number] | undefined; roughness?: number | undefined; metalness?: number | undefined; maps?: { colour: (string) | null; normal: (string) | null; orm: (string) | null; } | undefined; normalScale?: number | undefined; occlusion?: number | undefined; envStrength?: number | undefined; vertexColours?: boolean | undefined; faceted?: boolean | undefined; doubleSided?: boolean | undefined; alphaCutoff?: number | undefined; ground?: (GroundLayerParamsInput) | null | undefined; measure?: (MeasureLayerParamsInput) | null | undefined; detail?: DetailLayer; emissive?: [number, number, number]; emissiveIntensity?: number; blend?: 'opaque' | 'alpha'; opacity?: number; depthOffset?: number; sway?: SurfaceSway; uvScroll?: [number, number]; }
|
|
573
|
+
export interface PbrMaterialParamsInput { family: 'pbr'; colour?: [number, number, number] | undefined; roughness?: number | undefined; metalness?: number | undefined; maps?: { colour: (string) | null; normal: (string) | null; orm: (string) | null; } | undefined; normalScale?: number | undefined; occlusion?: number | undefined; envStrength?: number | undefined; vertexColours?: boolean | undefined; faceted?: boolean | undefined; doubleSided?: boolean | undefined; alphaCutoff?: number | undefined; ground?: (GroundLayerParamsInput) | null | undefined; measure?: (MeasureLayerParamsInput) | null | undefined; detail?: DetailLayer; emissive?: [number, number, number]; emissiveIntensity?: number; blend?: 'opaque' | 'alpha'; opacity?: number; depthOffset?: number; sway?: SurfaceSway; uvScroll?: [number, number]; swing?: true; }
|
|
570
574
|
// oxlint-disable-next-line typescript/consistent-type-definitions -- Graph admission requires the material alias's implicit dictionary compatibility.
|
|
571
|
-
export type PbrMaterialParams = { family: 'pbr'; colour: [number, number, number]; roughness: number; metalness: number; maps: { colour: (string) | null; normal: (string) | null; orm: (string) | null; }; normalScale: number; occlusion: number; envStrength: number; vertexColours: boolean; faceted: boolean; doubleSided: boolean; alphaCutoff: number; ground: (GroundLayerParams) | null; measure: (MeasureLayerParams) | null; detail?: DetailLayer; emissive?: [number, number, number]; emissiveIntensity?: number; blend?: 'opaque' | 'alpha'; opacity?: number; depthOffset?: number; sway?: SurfaceSway; uvScroll?: [number, number]; };
|
|
575
|
+
export type PbrMaterialParams = { family: 'pbr'; colour: [number, number, number]; roughness: number; metalness: number; maps: { colour: (string) | null; normal: (string) | null; orm: (string) | null; }; normalScale: number; occlusion: number; envStrength: number; vertexColours: boolean; faceted: boolean; doubleSided: boolean; alphaCutoff: number; ground: (GroundLayerParams) | null; measure: (MeasureLayerParams) | null; detail?: DetailLayer; emissive?: [number, number, number]; emissiveIntensity?: number; blend?: 'opaque' | 'alpha'; opacity?: number; depthOffset?: number; sway?: SurfaceSway; uvScroll?: [number, number]; swing?: true; };
|
|
572
576
|
export interface GradeParamsInput { exposure?: number | undefined; gain?: number | undefined; shoulder?: number | undefined; saturation?: number | undefined; shadowTint?: [number, number, number] | undefined; lightTint?: [number, number, number] | undefined; split?: [number, number] | undefined; contrast?: number | undefined; lookSaturation?: number | undefined; }
|
|
573
577
|
export interface GradeParams { exposure: number; gain: number; shoulder: number; saturation: number; shadowTint: [number, number, number]; lightTint: [number, number, number]; split: [number, number]; contrast: number; lookSaturation: number; }
|
|
574
578
|
export interface PainterlyLookParamsInput { shade?: [number, number, number] | undefined; rim?: [number, number, number] | undefined; warm?: number | undefined; floor?: number | undefined; wet?: number | undefined; wind?: { direction: [number, number]; strength: number; } | undefined; grade?: (GradeParamsInput) | null | undefined; }
|
|
@@ -584,8 +588,8 @@ export interface NeonTubeParamsInput { field: string; fillSpread: number; skelet
|
|
|
584
588
|
export interface NeonTubeParams { field: string; fillSpread: number; skeletonSpread: number; mono: number; radius: number; rim: number; thicken: number; seam: number; seamWidth: number; haloReach: number; haloGain: number; core: number; rimShade: number; cell: ([number, number]) | null; }
|
|
585
589
|
export interface SkyDomeParamsInput { maps: [string, (string) | null]; elevation?: [number, number] | undefined; window?: [number, number] | undefined; firstGain?: [number, number] | undefined; hold?: number | undefined; stars?: { density: number; gain: number; elevation: [number, number]; appear: [number, number]; } | undefined; dither?: number | undefined; }
|
|
586
590
|
export interface SkyDomeParams { maps: [string, (string) | null]; elevation: [number, number]; window: [number, number]; firstGain: [number, number]; hold: number; stars: { density: number; gain: number; elevation: [number, number]; appear: [number, number]; }; dither: number; }
|
|
587
|
-
export interface EmissiveMaterialParamsInput { family: 'emissive'; colour?: [number, number, number] | undefined; intensity?: number | undefined; vertexColours?: boolean | undefined; map?: (string) | null | undefined; blend?: 'opaque' | 'additive' | 'alpha' | undefined; doubleSided?: boolean | undefined; fog?: number | undefined; flicker?: number | undefined; tube?: (NeonTubeParamsInput) | null | undefined; sky?: (SkyDomeParamsInput) | null | undefined; card?: true; motion?: CardMotion; }
|
|
591
|
+
export interface EmissiveMaterialParamsInput { family: 'emissive'; colour?: [number, number, number] | undefined; intensity?: number | undefined; vertexColours?: boolean | undefined; map?: (string) | null | undefined; blend?: 'opaque' | 'additive' | 'alpha' | undefined; doubleSided?: boolean | undefined; fog?: number | undefined; flicker?: number | undefined; tube?: (NeonTubeParamsInput) | null | undefined; sky?: (SkyDomeParamsInput) | null | undefined; card?: true; motion?: CardMotion; swing?: true; }
|
|
588
592
|
// oxlint-disable-next-line typescript/consistent-type-definitions -- Graph admission requires the material alias's implicit dictionary compatibility.
|
|
589
|
-
export type EmissiveMaterialParams = { family: 'emissive'; colour: [number, number, number]; intensity: number; vertexColours: boolean; map: (string) | null; blend: 'opaque' | 'additive' | 'alpha'; doubleSided: boolean; fog: number; flicker: number; tube: (NeonTubeParams) | null; sky: (SkyDomeParams) | null; card?: true; motion?: CardMotion; };
|
|
593
|
+
export type EmissiveMaterialParams = { family: 'emissive'; colour: [number, number, number]; intensity: number; vertexColours: boolean; map: (string) | null; blend: 'opaque' | 'additive' | 'alpha'; doubleSided: boolean; fog: number; flicker: number; tube: (NeonTubeParams) | null; sky: (SkyDomeParams) | null; card?: true; motion?: CardMotion; swing?: true; };
|
|
590
594
|
export type FamilyMaterialParamsInput = (ToonMaterialParamsInput) | (PbrMaterialParamsInput) | (PainterlyMaterialParamsInput) | (EmissiveMaterialParamsInput);
|
|
591
595
|
export type FamilyMaterialParams = (ToonMaterialParams) | (PbrMaterialParams) | (PainterlyMaterialParams) | (EmissiveMaterialParams);
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
* - `sway`: foliage in the wind. Each vertex moves by its `_SWAY` vertex channel (metres, one float: 0 at the root) along
|
|
12
12
|
* `direction` (x, z) at about `rate` hertz, its phase taken from where it stands.
|
|
13
13
|
* - `uvScroll`: the colour map's uv moves this many units a second (u, v): running water, drifting cloud shadow.
|
|
14
|
+
* - `swing: true` (meta SHARD-SOURCE SS8b, PBR and emissive): a hanging body. Each vertex's `_SWING` channel (one float)
|
|
15
|
+
* names the look's `look.light.swings` row it hangs from, plus one (0: it stays still); the engine turns the vertex
|
|
16
|
+
* (and a card's seat) round that swing's pivot by the swing's tilt each frame, the way a lamp, a sign or a banner hangs.
|
|
14
17
|
*
|
|
15
18
|
* Emissive family:
|
|
16
19
|
* - `blend: 'alpha'` (beside `opaque` and `additive`): an unlit card blended over what is behind it (a flame tongue).
|
|
@@ -132,6 +135,11 @@ const emissiveCard: ExactOptionalSchema<
|
|
|
132
135
|
GenericSchema<true, true>,
|
|
133
136
|
undefined
|
|
134
137
|
> = exactOptional(literal(true))
|
|
138
|
+
/** PBR and emissive `swing` (SS8b): the `_SWING` channel names each vertex's swing. */
|
|
139
|
+
const surfaceSwing: ExactOptionalSchema<
|
|
140
|
+
GenericSchema<true, true>,
|
|
141
|
+
undefined
|
|
142
|
+
> = exactOptional(literal(true))
|
|
135
143
|
/** Emissive `motion`. */
|
|
136
144
|
const emissiveMotion: ExactOptionalSchema<
|
|
137
145
|
GenericSchema<CardMotion, CardMotion>,
|
|
@@ -140,6 +148,8 @@ const emissiveMotion: ExactOptionalSchema<
|
|
|
140
148
|
|
|
141
149
|
/** The vertex channel a swaying surface reads (GLB application attribute `_SWAY`, one float, metres). */
|
|
142
150
|
const SWAY_CHANNEL = '_SWAY'
|
|
151
|
+
/** The vertex channel a swinging surface reads (GLB application attribute `_SWING`, one float: swing number + 1, 0 still). */
|
|
152
|
+
const SWING_CHANNEL = '_SWING'
|
|
143
153
|
/** The vertex channel a card reads (GLB application attribute `_CORNER`, two floats, metres in view space). */
|
|
144
154
|
const CORNER_CHANNEL = '_CORNER'
|
|
145
155
|
|
|
@@ -147,6 +157,7 @@ export {
|
|
|
147
157
|
CORNER_CHANNEL,
|
|
148
158
|
CardMotionSchema,
|
|
149
159
|
SWAY_CHANNEL,
|
|
160
|
+
SWING_CHANNEL,
|
|
150
161
|
SurfaceSwaySchema,
|
|
151
162
|
UvScrollSchema,
|
|
152
163
|
emissiveCard,
|
|
@@ -155,6 +166,7 @@ export {
|
|
|
155
166
|
surfaceDepthOffset,
|
|
156
167
|
surfaceOpacity,
|
|
157
168
|
surfaceSway,
|
|
169
|
+
surfaceSwing,
|
|
158
170
|
surfaceUvScroll,
|
|
159
171
|
}
|
|
160
172
|
export type { CardMotion, SurfaceSway }
|