@flighthq/shading 0.2.1-next.410.a23f189
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/dist/createAnimatedNormalModifier.d.ts +10 -0
- package/dist/createAnimatedNormalModifier.d.ts.map +1 -0
- package/dist/createAnimatedNormalModifier.js +22 -0
- package/dist/createAnimatedNormalModifier.js.map +1 -0
- package/dist/createDissolveModifier.d.ts +10 -0
- package/dist/createDissolveModifier.d.ts.map +1 -0
- package/dist/createDissolveModifier.js +21 -0
- package/dist/createDissolveModifier.js.map +1 -0
- package/dist/createEmissiveModifier.d.ts +11 -0
- package/dist/createEmissiveModifier.d.ts.map +1 -0
- package/dist/createEmissiveModifier.js +21 -0
- package/dist/createEmissiveModifier.js.map +1 -0
- package/dist/createEnvReflectModifier.d.ts +9 -0
- package/dist/createEnvReflectModifier.d.ts.map +1 -0
- package/dist/createEnvReflectModifier.js +18 -0
- package/dist/createEnvReflectModifier.js.map +1 -0
- package/dist/createFogModifier.d.ts +11 -0
- package/dist/createFogModifier.d.ts.map +1 -0
- package/dist/createFogModifier.js +18 -0
- package/dist/createFogModifier.js.map +1 -0
- package/dist/createRimModifier.d.ts +9 -0
- package/dist/createRimModifier.d.ts.map +1 -0
- package/dist/createRimModifier.js +17 -0
- package/dist/createRimModifier.js.map +1 -0
- package/dist/createShadedMaterial.d.ts +13 -0
- package/dist/createShadedMaterial.d.ts.map +1 -0
- package/dist/createShadedMaterial.js +28 -0
- package/dist/createShadedMaterial.js.map +1 -0
- package/dist/createToonModifier.d.ts +7 -0
- package/dist/createToonModifier.d.ts.map +1 -0
- package/dist/createToonModifier.js +15 -0
- package/dist/createToonModifier.js.map +1 -0
- package/dist/createVertexDisplaceModifier.d.ts +13 -0
- package/dist/createVertexDisplaceModifier.d.ts.map +1 -0
- package/dist/createVertexDisplaceModifier.js +24 -0
- package/dist/createVertexDisplaceModifier.js.map +1 -0
- package/dist/getModifierDefineKey.d.ts +4 -0
- package/dist/getModifierDefineKey.d.ts.map +1 -0
- package/dist/getModifierDefineKey.js +36 -0
- package/dist/getModifierDefineKey.js.map +1 -0
- package/dist/getUnregisteredModifierKinds.d.ts +4 -0
- package/dist/getUnregisteredModifierKinds.d.ts.map +1 -0
- package/dist/getUnregisteredModifierKinds.js +17 -0
- package/dist/getUnregisteredModifierKinds.js.map +1 -0
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +17 -0
- package/dist/index.js.map +1 -0
- package/dist/isBuiltInModifierSlot.d.ts +2 -0
- package/dist/isBuiltInModifierSlot.d.ts.map +1 -0
- package/dist/isBuiltInModifierSlot.js +18 -0
- package/dist/isBuiltInModifierSlot.js.map +1 -0
- package/dist/isModifierStackValid.d.ts +4 -0
- package/dist/isModifierStackValid.d.ts.map +1 -0
- package/dist/isModifierStackValid.js +8 -0
- package/dist/isModifierStackValid.js.map +1 -0
- package/dist/modifierRegistry.d.ts +13 -0
- package/dist/modifierRegistry.d.ts.map +1 -0
- package/dist/modifierRegistry.js +18 -0
- package/dist/modifierRegistry.js.map +1 -0
- package/dist/orderModifierStack.d.ts +3 -0
- package/dist/orderModifierStack.d.ts.map +1 -0
- package/dist/orderModifierStack.js +36 -0
- package/dist/orderModifierStack.js.map +1 -0
- package/dist/registerBuiltInModifiers.d.ts +11 -0
- package/dist/registerBuiltInModifiers.d.ts.map +1 -0
- package/dist/registerBuiltInModifiers.js +108 -0
- package/dist/registerBuiltInModifiers.js.map +1 -0
- package/package.json +43 -0
- package/src/createAnimatedNormalModifier.test.ts +49 -0
- package/src/createDissolveModifier.test.ts +30 -0
- package/src/createEmissiveModifier.test.ts +44 -0
- package/src/createEnvReflectModifier.test.ts +28 -0
- package/src/createFogModifier.test.ts +31 -0
- package/src/createRimModifier.test.ts +31 -0
- package/src/createShadedMaterial.test.ts +45 -0
- package/src/createToonModifier.test.ts +23 -0
- package/src/createVertexDisplaceModifier.test.ts +36 -0
- package/src/getModifierDefineKey.test.ts +74 -0
- package/src/getUnregisteredModifierKinds.test.ts +40 -0
- package/src/isBuiltInModifierSlot.test.ts +25 -0
- package/src/isModifierStackValid.test.ts +27 -0
- package/src/modifierRegistry.test.ts +59 -0
- package/src/orderModifierStack.test.ts +48 -0
- package/src/registerBuiltInModifiers.test.ts +118 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AnimatedNormalModifier, Texture, Vector2Like } from '@flighthq/types';
|
|
2
|
+
export interface AnimatedNormalModifierOptions {
|
|
3
|
+
map: Texture | null;
|
|
4
|
+
scroll: Vector2Like;
|
|
5
|
+
strength?: number;
|
|
6
|
+
secondaryMap?: Texture;
|
|
7
|
+
secondaryScroll?: Vector2Like;
|
|
8
|
+
}
|
|
9
|
+
export declare function createAnimatedNormalModifier(options: Readonly<AnimatedNormalModifierOptions>): AnimatedNormalModifier;
|
|
10
|
+
//# sourceMappingURL=createAnimatedNormalModifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createAnimatedNormalModifier.d.ts","sourceRoot":"","sources":["../src/createAnimatedNormalModifier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAOpF,MAAM,WAAW,6BAA6B;IAC5C,GAAG,EAAE,OAAO,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,WAAW,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,eAAe,CAAC,EAAE,WAAW,CAAC;CAC/B;AAQD,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,QAAQ,CAAC,6BAA6B,CAAC,GAAG,sBAAsB,CAWrH"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { AnimatedNormalModifierKind, ModifierSlot } from '@flighthq/types';
|
|
2
|
+
// Builds an AnimatedNormalModifier (slot: Normal) — a UV-panned normal map that perturbs the surface
|
|
3
|
+
// normal, scrolled by the shading tier's per-frame `time` uniform. Covers animated water, lava, and
|
|
4
|
+
// flow. `scroll` is the pan speed in UV units per second (a plain Vector2Like value, copied by
|
|
5
|
+
// reference); `strength` defaults to 1. An optional `secondaryMap` (+ `secondaryScroll`) adds a
|
|
6
|
+
// second layer panning at a different rate to break up tiling — omitted leaves the modifier a single
|
|
7
|
+
// layer.
|
|
8
|
+
export function createAnimatedNormalModifier(options) {
|
|
9
|
+
const modifier = {
|
|
10
|
+
kind: AnimatedNormalModifierKind,
|
|
11
|
+
slot: ModifierSlot.Normal,
|
|
12
|
+
map: options.map,
|
|
13
|
+
scroll: options.scroll,
|
|
14
|
+
strength: options.strength ?? 1,
|
|
15
|
+
};
|
|
16
|
+
if (options.secondaryMap !== undefined)
|
|
17
|
+
modifier.secondaryMap = options.secondaryMap;
|
|
18
|
+
if (options.secondaryScroll !== undefined)
|
|
19
|
+
modifier.secondaryScroll = options.secondaryScroll;
|
|
20
|
+
return modifier;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=createAnimatedNormalModifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createAnimatedNormalModifier.js","sourceRoot":"","sources":["../src/createAnimatedNormalModifier.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,0BAA0B,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAc3E,qGAAqG;AACrG,oGAAoG;AACpG,+FAA+F;AAC/F,gGAAgG;AAChG,qGAAqG;AACrG,SAAS;AACT,MAAM,UAAU,4BAA4B,CAAC,OAAgD;IAC3F,MAAM,QAAQ,GAA2B;QACvC,IAAI,EAAE,0BAA0B;QAChC,IAAI,EAAE,YAAY,CAAC,MAAM;QACzB,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,CAAC;KAChC,CAAC;IACF,IAAI,OAAO,CAAC,YAAY,KAAK,SAAS;QAAE,QAAQ,CAAC,YAAY,GAAG,OAAO,CAAC,YAAY,CAAC;IACrF,IAAI,OAAO,CAAC,eAAe,KAAK,SAAS;QAAE,QAAQ,CAAC,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC;IAC9F,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DissolveModifier, Texture } from '@flighthq/types';
|
|
2
|
+
export interface DissolveModifierOptions {
|
|
3
|
+
threshold: number;
|
|
4
|
+
edgeColor?: number;
|
|
5
|
+
edgeWidth?: number;
|
|
6
|
+
map?: Texture;
|
|
7
|
+
scale?: number;
|
|
8
|
+
}
|
|
9
|
+
export declare function createDissolveModifier(options: Readonly<DissolveModifierOptions>): DissolveModifier;
|
|
10
|
+
//# sourceMappingURL=createDissolveModifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createDissolveModifier.d.ts","sourceRoot":"","sources":["../src/createDissolveModifier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAMjE,MAAM,WAAW,uBAAuB;IACtC,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAQD,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,QAAQ,CAAC,uBAAuB,CAAC,GAAG,gBAAgB,CAWnG"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DissolveModifierKind, ModifierSlot } from '@flighthq/types';
|
|
2
|
+
// Builds a DissolveModifier (slot: Effect) — a clip/burn dissolve of the shaded output. A per-fragment
|
|
3
|
+
// noise value (procedural over the UV, or sampled from `map`'s red channel) is compared against
|
|
4
|
+
// `threshold`; fragments below it are discarded and a band of width `edgeWidth` above it glows
|
|
5
|
+
// `edgeColor`. Animate `threshold` from 0 to 1 to disintegrate the surface. `edgeColor` is packed sRgb
|
|
6
|
+
// RGBA (default 0xff6600ff); `edgeWidth` defaults to 0.05 (0 = hard clip); `scale` (procedural-noise
|
|
7
|
+
// frequency, ignored with `map`) defaults to 8. `map` is copied by reference only when provided.
|
|
8
|
+
export function createDissolveModifier(options) {
|
|
9
|
+
const modifier = {
|
|
10
|
+
kind: DissolveModifierKind,
|
|
11
|
+
slot: ModifierSlot.Effect,
|
|
12
|
+
threshold: options.threshold,
|
|
13
|
+
edgeColor: options.edgeColor ?? 0xff6600ff,
|
|
14
|
+
edgeWidth: options.edgeWidth ?? 0.05,
|
|
15
|
+
scale: options.scale ?? 8,
|
|
16
|
+
};
|
|
17
|
+
if (options.map !== undefined)
|
|
18
|
+
modifier.map = options.map;
|
|
19
|
+
return modifier;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=createDissolveModifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createDissolveModifier.js","sourceRoot":"","sources":["../src/createDissolveModifier.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAarE,uGAAuG;AACvG,gGAAgG;AAChG,+FAA+F;AAC/F,uGAAuG;AACvG,qGAAqG;AACrG,iGAAiG;AACjG,MAAM,UAAU,sBAAsB,CAAC,OAA0C;IAC/E,MAAM,QAAQ,GAAqB;QACjC,IAAI,EAAE,oBAAoB;QAC1B,IAAI,EAAE,YAAY,CAAC,MAAM;QACzB,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,UAAU;QAC1C,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,IAAI;QACpC,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;KAC1B,CAAC;IACF,IAAI,OAAO,CAAC,GAAG,KAAK,SAAS;QAAE,QAAQ,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAC1D,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { EmissiveModifier, Texture } from '@flighthq/types';
|
|
2
|
+
import { EmissiveModifierFacing } from '@flighthq/types';
|
|
3
|
+
export interface EmissiveModifierOptions {
|
|
4
|
+
color: number;
|
|
5
|
+
strength?: number;
|
|
6
|
+
mask?: Texture;
|
|
7
|
+
facing?: EmissiveModifierFacing;
|
|
8
|
+
facingSoftness?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare function createEmissiveModifier(options: Readonly<EmissiveModifierOptions>): EmissiveModifier;
|
|
11
|
+
//# sourceMappingURL=createEmissiveModifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createEmissiveModifier.d.ts","sourceRoot":"","sources":["../src/createEmissiveModifier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAE,sBAAsB,EAAsC,MAAM,iBAAiB,CAAC;AAM7F,MAAM,WAAW,uBAAuB;IACtC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,sBAAsB,CAAC;IAChC,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAQD,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,QAAQ,CAAC,uBAAuB,CAAC,GAAG,gBAAgB,CAWnG"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { EmissiveModifierFacing, EmissiveModifierKind, ModifierSlot } from '@flighthq/types';
|
|
2
|
+
// Builds an EmissiveModifier (slot: Emissive) — a self-illuminating contribution added to the shaded
|
|
3
|
+
// output, optionally masked and optionally gated by surface facing (the night-side city-lights case
|
|
4
|
+
// uses `AwayFromLight`). `color` is packed sRgb-albedo RGBA (0xrrggbbaa); `strength` scales linear
|
|
5
|
+
// radiance and defaults to 1; `facing` defaults to Ignore (emit everywhere) and `facingSoftness` to
|
|
6
|
+
// 0 (a hard terminator). `mask` is copied by reference only when provided — omitted leaves the
|
|
7
|
+
// descriptor unmasked.
|
|
8
|
+
export function createEmissiveModifier(options) {
|
|
9
|
+
const modifier = {
|
|
10
|
+
kind: EmissiveModifierKind,
|
|
11
|
+
slot: ModifierSlot.Emissive,
|
|
12
|
+
color: options.color,
|
|
13
|
+
strength: options.strength ?? 1,
|
|
14
|
+
facing: options.facing ?? EmissiveModifierFacing.Ignore,
|
|
15
|
+
facingSoftness: options.facingSoftness ?? 0,
|
|
16
|
+
};
|
|
17
|
+
if (options.mask !== undefined)
|
|
18
|
+
modifier.mask = options.mask;
|
|
19
|
+
return modifier;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=createEmissiveModifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createEmissiveModifier.js","sourceRoot":"","sources":["../src/createEmissiveModifier.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAc7F,qGAAqG;AACrG,oGAAoG;AACpG,mGAAmG;AACnG,oGAAoG;AACpG,+FAA+F;AAC/F,uBAAuB;AACvB,MAAM,UAAU,sBAAsB,CAAC,OAA0C;IAC/E,MAAM,QAAQ,GAAqB;QACjC,IAAI,EAAE,oBAAoB;QAC1B,IAAI,EAAE,YAAY,CAAC,QAAQ;QAC3B,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,QAAQ,EAAE,OAAO,CAAC,QAAQ,IAAI,CAAC;QAC/B,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,sBAAsB,CAAC,MAAM;QACvD,cAAc,EAAE,OAAO,CAAC,cAAc,IAAI,CAAC;KAC5C,CAAC;IACF,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS;QAAE,QAAQ,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAC7D,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { EnvReflectModifier } from '@flighthq/types';
|
|
2
|
+
export interface EnvReflectModifierOptions {
|
|
3
|
+
tint?: number;
|
|
4
|
+
intensity?: number;
|
|
5
|
+
fresnelBias?: number;
|
|
6
|
+
roughness?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function createEnvReflectModifier(options?: Readonly<EnvReflectModifierOptions>): EnvReflectModifier;
|
|
9
|
+
//# sourceMappingURL=createEnvReflectModifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createEnvReflectModifier.d.ts","sourceRoot":"","sources":["../src/createEnvReflectModifier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAM1D,MAAM,WAAW,yBAAyB;IACxC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAQD,wBAAgB,wBAAwB,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,yBAAyB,CAAC,GAAG,kBAAkB,CAS1G"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { EnvReflectModifierKind, ModifierSlot } from '@flighthq/types';
|
|
2
|
+
// Builds an EnvReflectModifier (slot: Effect) — a view-dependent reflection of the scene's baked
|
|
3
|
+
// environment cubemap added to the shaded output. It samples the SAME prefiltered environment the lit
|
|
4
|
+
// block already binds (no second cubemap), reflecting the view vector about the surface normal and
|
|
5
|
+
// blending by a Fresnel-Schlick ramp. `tint` is packed sRgb RGBA over the sampled color and defaults
|
|
6
|
+
// to opaque white; `intensity` scales the whole term (default 1); `fresnelBias` is f0 (default 0.04,
|
|
7
|
+
// a dielectric); `roughness` selects a blurrier prefiltered mip (default 0 = mirror-sharp).
|
|
8
|
+
export function createEnvReflectModifier(options) {
|
|
9
|
+
return {
|
|
10
|
+
kind: EnvReflectModifierKind,
|
|
11
|
+
slot: ModifierSlot.Effect,
|
|
12
|
+
tint: options?.tint ?? 0xffffffff,
|
|
13
|
+
intensity: options?.intensity ?? 1,
|
|
14
|
+
fresnelBias: options?.fresnelBias ?? 0.04,
|
|
15
|
+
roughness: options?.roughness ?? 0,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=createEnvReflectModifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createEnvReflectModifier.js","sourceRoot":"","sources":["../src/createEnvReflectModifier.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAYvE,iGAAiG;AACjG,sGAAsG;AACtG,mGAAmG;AACnG,qGAAqG;AACrG,qGAAqG;AACrG,4FAA4F;AAC5F,MAAM,UAAU,wBAAwB,CAAC,OAA6C;IACpF,OAAO;QACL,IAAI,EAAE,sBAAsB;QAC5B,IAAI,EAAE,YAAY,CAAC,MAAM;QACzB,IAAI,EAAE,OAAO,EAAE,IAAI,IAAI,UAAU;QACjC,SAAS,EAAE,OAAO,EAAE,SAAS,IAAI,CAAC;QAClC,WAAW,EAAE,OAAO,EAAE,WAAW,IAAI,IAAI;QACzC,SAAS,EAAE,OAAO,EAAE,SAAS,IAAI,CAAC;KACnC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FogModifier } from '@flighthq/types';
|
|
2
|
+
import { FogModifierMode } from '@flighthq/types';
|
|
3
|
+
export interface FogModifierOptions {
|
|
4
|
+
color: number;
|
|
5
|
+
mode?: FogModifierMode;
|
|
6
|
+
near?: number;
|
|
7
|
+
far?: number;
|
|
8
|
+
density?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare function createFogModifier(options: Readonly<FogModifierOptions>): FogModifier;
|
|
11
|
+
//# sourceMappingURL=createFogModifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createFogModifier.d.ts","sourceRoot":"","sources":["../src/createFogModifier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAmB,eAAe,EAAgB,MAAM,iBAAiB,CAAC;AAMjF,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAOD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,QAAQ,CAAC,kBAAkB,CAAC,GAAG,WAAW,CAUpF"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FogModifierKind, FogModifierMode, ModifierSlot } from '@flighthq/types';
|
|
2
|
+
// Builds a FogModifier (slot: Effect) — blends the shaded output toward `color` by camera-distance
|
|
3
|
+
// density. `color` is packed sRgb RGBA. `mode` defaults to Linear (using `near`/`far` as the ramp
|
|
4
|
+
// endpoints, defaults 0 and 1); the Exponential/Exponential2 modes use `density` (default 1) as the
|
|
5
|
+
// falloff rate. This is the per-material forward-shaded fog term, the compiled sibling of the
|
|
6
|
+
// post-process ScreenSpaceFogEffect.
|
|
7
|
+
export function createFogModifier(options) {
|
|
8
|
+
return {
|
|
9
|
+
kind: FogModifierKind,
|
|
10
|
+
slot: ModifierSlot.Effect,
|
|
11
|
+
color: options.color,
|
|
12
|
+
mode: options.mode ?? FogModifierMode.Linear,
|
|
13
|
+
near: options.near ?? 0,
|
|
14
|
+
far: options.far ?? 1,
|
|
15
|
+
density: options.density ?? 1,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=createFogModifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createFogModifier.js","sourceRoot":"","sources":["../src/createFogModifier.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAcjF,mGAAmG;AACnG,kGAAkG;AAClG,oGAAoG;AACpG,8FAA8F;AAC9F,qCAAqC;AACrC,MAAM,UAAU,iBAAiB,CAAC,OAAqC;IACrE,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,IAAI,EAAE,YAAY,CAAC,MAAM;QACzB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,eAAe,CAAC,MAAM;QAC5C,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC;QACvB,GAAG,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;QACrB,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,CAAC;KAC9B,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { RimModifier } from '@flighthq/types';
|
|
2
|
+
export interface RimModifierOptions {
|
|
3
|
+
color: number;
|
|
4
|
+
power?: number;
|
|
5
|
+
intensity?: number;
|
|
6
|
+
bias?: number;
|
|
7
|
+
}
|
|
8
|
+
export declare function createRimModifier(options: Readonly<RimModifierOptions>): RimModifier;
|
|
9
|
+
//# sourceMappingURL=createRimModifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createRimModifier.d.ts","sourceRoot":"","sources":["../src/createRimModifier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAMnD,MAAM,WAAW,kBAAkB;IACjC,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAOD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,QAAQ,CAAC,kBAAkB,CAAC,GAAG,WAAW,CASpF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ModifierSlot, RimModifierKind } from '@flighthq/types';
|
|
2
|
+
// Builds a RimModifier (slot: Effect) — a view-dependent Fresnel rim added to the shaded output at
|
|
3
|
+
// grazing angles, following `bias + intensity * pow(1 - dot(N, V), power)`. Covers the atmospheric
|
|
4
|
+
// halo, force-field shields, and NPR rim light. `color` is packed sRgb-albedo RGBA (0xrrggbbaa);
|
|
5
|
+
// `power` (falloff exponent, higher = tighter) defaults to 3, `intensity` to 1, and `bias` (the
|
|
6
|
+
// constant floor before the falloff) to 0 (pure Fresnel).
|
|
7
|
+
export function createRimModifier(options) {
|
|
8
|
+
return {
|
|
9
|
+
kind: RimModifierKind,
|
|
10
|
+
slot: ModifierSlot.Effect,
|
|
11
|
+
color: options.color,
|
|
12
|
+
power: options.power ?? 3,
|
|
13
|
+
intensity: options.intensity ?? 1,
|
|
14
|
+
bias: options.bias ?? 0,
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=createRimModifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createRimModifier.js","sourceRoot":"","sources":["../src/createRimModifier.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAYhE,mGAAmG;AACnG,mGAAmG;AACnG,iGAAiG;AACjG,gGAAgG;AAChG,0DAA0D;AAC1D,MAAM,UAAU,iBAAiB,CAAC,OAAqC;IACrE,OAAO;QACL,IAAI,EAAE,eAAe;QACrB,IAAI,EAAE,YAAY,CAAC,MAAM;QACzB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;QACzB,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,CAAC;QACjC,IAAI,EAAE,OAAO,CAAC,IAAI,IAAI,CAAC;KACxB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Modifier, ShadedMaterial } from '@flighthq/types';
|
|
2
|
+
export interface ShadedMaterialOptions {
|
|
3
|
+
diffuse?: number;
|
|
4
|
+
diffuseMap?: ShadedMaterial['diffuseMap'];
|
|
5
|
+
modifiers?: readonly Modifier[];
|
|
6
|
+
normalMap?: ShadedMaterial['normalMap'];
|
|
7
|
+
normalScale?: number;
|
|
8
|
+
shininess?: number;
|
|
9
|
+
specular?: number;
|
|
10
|
+
specularMap?: ShadedMaterial['specularMap'];
|
|
11
|
+
}
|
|
12
|
+
export declare function createShadedMaterial(options?: Readonly<ShadedMaterialOptions>): ShadedMaterial;
|
|
13
|
+
//# sourceMappingURL=createShadedMaterial.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createShadedMaterial.d.ts","sourceRoot":"","sources":["../src/createShadedMaterial.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAMhE,MAAM,WAAW,qBAAqB;IACpC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,cAAc,CAAC,YAAY,CAAC,CAAC;IAC1C,SAAS,CAAC,EAAE,SAAS,QAAQ,EAAE,CAAC;IAChC,SAAS,CAAC,EAAE,cAAc,CAAC,WAAW,CAAC,CAAC;IACxC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,WAAW,CAAC,EAAE,cAAc,CAAC,aAAa,CAAC,CAAC;CAC7C;AAUD,wBAAgB,oBAAoB,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,qBAAqB,CAAC,GAAG,cAAc,CAgB9F"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createEntity } from '@flighthq/entity';
|
|
2
|
+
import { BlendMode, ShadedMaterialKind } from '@flighthq/types';
|
|
3
|
+
// Builds the composable lit base material owned by @flighthq/shading — a diffuse + half-vector
|
|
4
|
+
// specular surface carrying an ordered `modifiers` stack that the per-backend compile path assembles
|
|
5
|
+
// over the shared light block into one program keyed by the stack's define-key. This is the ONLY
|
|
6
|
+
// base modifiers attach to in v1. `diffuse`/`specular` are packed sRgb-albedo RGBA (0xrrggbbaa) and
|
|
7
|
+
// default to opaque white; `shininess` (the specular exponent) defaults to 32; `normalScale` to 1;
|
|
8
|
+
// all maps to null; `modifiers` to an empty stack. The shared SurfaceMaterial trailer starts opaque,
|
|
9
|
+
// single-sided, straight alpha, Normal blend, 0.5 mask cutoff — mutate the returned entity to change
|
|
10
|
+
// them. The result is an entity (it carries runtime/binding identity), not a plain literal.
|
|
11
|
+
export function createShadedMaterial(options) {
|
|
12
|
+
const material = createEntity({ kind: ShadedMaterialKind });
|
|
13
|
+
material.alphaCutoff = 0.5;
|
|
14
|
+
material.alphaMode = 'opaque';
|
|
15
|
+
material.alphaType = 'straight';
|
|
16
|
+
material.blendMode = BlendMode.Normal;
|
|
17
|
+
material.diffuse = options?.diffuse ?? 0xffffffff;
|
|
18
|
+
material.diffuseMap = options?.diffuseMap ?? null;
|
|
19
|
+
material.doubleSided = false;
|
|
20
|
+
material.modifiers = options?.modifiers ?? [];
|
|
21
|
+
material.normalMap = options?.normalMap ?? null;
|
|
22
|
+
material.normalScale = options?.normalScale ?? 1;
|
|
23
|
+
material.shininess = options?.shininess ?? 32;
|
|
24
|
+
material.specular = options?.specular ?? 0xffffffff;
|
|
25
|
+
material.specularMap = options?.specularMap ?? null;
|
|
26
|
+
return material;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=createShadedMaterial.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createShadedMaterial.js","sourceRoot":"","sources":["../src/createShadedMaterial.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAgBhE,+FAA+F;AAC/F,qGAAqG;AACrG,iGAAiG;AACjG,oGAAoG;AACpG,mGAAmG;AACnG,qGAAqG;AACrG,qGAAqG;AACrG,4FAA4F;AAC5F,MAAM,UAAU,oBAAoB,CAAC,OAAyC;IAC5E,MAAM,QAAQ,GAAG,YAAY,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,CAAmB,CAAC;IAC9E,QAAQ,CAAC,WAAW,GAAG,GAAG,CAAC;IAC3B,QAAQ,CAAC,SAAS,GAAG,QAAQ,CAAC;IAC9B,QAAQ,CAAC,SAAS,GAAG,UAAU,CAAC;IAChC,QAAQ,CAAC,SAAS,GAAG,SAAS,CAAC,MAAM,CAAC;IACtC,QAAQ,CAAC,OAAO,GAAG,OAAO,EAAE,OAAO,IAAI,UAAU,CAAC;IAClD,QAAQ,CAAC,UAAU,GAAG,OAAO,EAAE,UAAU,IAAI,IAAI,CAAC;IAClD,QAAQ,CAAC,WAAW,GAAG,KAAK,CAAC;IAC7B,QAAQ,CAAC,SAAS,GAAG,OAAO,EAAE,SAAS,IAAI,EAAE,CAAC;IAC9C,QAAQ,CAAC,SAAS,GAAG,OAAO,EAAE,SAAS,IAAI,IAAI,CAAC;IAChD,QAAQ,CAAC,WAAW,GAAG,OAAO,EAAE,WAAW,IAAI,CAAC,CAAC;IACjD,QAAQ,CAAC,SAAS,GAAG,OAAO,EAAE,SAAS,IAAI,EAAE,CAAC;IAC9C,QAAQ,CAAC,QAAQ,GAAG,OAAO,EAAE,QAAQ,IAAI,UAAU,CAAC;IACpD,QAAQ,CAAC,WAAW,GAAG,OAAO,EAAE,WAAW,IAAI,IAAI,CAAC;IACpD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ToonModifier } from '@flighthq/types';
|
|
2
|
+
export interface ToonModifierOptions {
|
|
3
|
+
steps: number;
|
|
4
|
+
smoothness?: number;
|
|
5
|
+
}
|
|
6
|
+
export declare function createToonModifier(options: Readonly<ToonModifierOptions>): ToonModifier;
|
|
7
|
+
//# sourceMappingURL=createToonModifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createToonModifier.d.ts","sourceRoot":"","sources":["../src/createToonModifier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAMpD,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAOD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,QAAQ,CAAC,mBAAmB,CAAC,GAAG,YAAY,CAOvF"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ModifierSlot, ToonModifierKind } from '@flighthq/types';
|
|
2
|
+
// Builds a ToonModifier (slot: Effect) — quantizes the shaded radiance into `steps` flat cel bands,
|
|
3
|
+
// producing the hard light/shadow terminator of toon shading as a MODIFIER over the ShadedMaterial
|
|
4
|
+
// base (the compiled sibling of the standalone ToonMaterial, so a toon look stacks with emissive/rim/
|
|
5
|
+
// fog). `steps` is the number of shading bands (values below 2 clamp to 2 in the shader); `smoothness`
|
|
6
|
+
// softens each band edge and defaults to 0 (crisp cel edges).
|
|
7
|
+
export function createToonModifier(options) {
|
|
8
|
+
return {
|
|
9
|
+
kind: ToonModifierKind,
|
|
10
|
+
slot: ModifierSlot.Effect,
|
|
11
|
+
steps: options.steps,
|
|
12
|
+
smoothness: options.smoothness ?? 0,
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=createToonModifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createToonModifier.js","sourceRoot":"","sources":["../src/createToonModifier.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAUjE,oGAAoG;AACpG,mGAAmG;AACnG,sGAAsG;AACtG,uGAAuG;AACvG,8DAA8D;AAC9D,MAAM,UAAU,kBAAkB,CAAC,OAAsC;IACvE,OAAO;QACL,IAAI,EAAE,gBAAgB;QACtB,IAAI,EAAE,YAAY,CAAC,MAAM;QACzB,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,CAAC;KACpC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Texture, Vector3Like, VertexDisplaceModifierSource } from '@flighthq/types';
|
|
2
|
+
import type { VertexDisplaceModifier } from '@flighthq/types';
|
|
3
|
+
export interface VertexDisplaceModifierOptions {
|
|
4
|
+
source: VertexDisplaceModifierSource;
|
|
5
|
+
amplitude: number;
|
|
6
|
+
axis?: Vector3Like;
|
|
7
|
+
map?: Texture;
|
|
8
|
+
frequency?: number;
|
|
9
|
+
speed?: number;
|
|
10
|
+
direction?: Vector3Like;
|
|
11
|
+
}
|
|
12
|
+
export declare function createVertexDisplaceModifier(options: Readonly<VertexDisplaceModifierOptions>): VertexDisplaceModifier;
|
|
13
|
+
//# sourceMappingURL=createVertexDisplaceModifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createVertexDisplaceModifier.d.ts","sourceRoot":"","sources":["../src/createVertexDisplaceModifier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AAE1F,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAM9D,MAAM,WAAW,6BAA6B;IAC5C,MAAM,EAAE,4BAA4B,CAAC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,WAAW,CAAC;CACzB;AAOD,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,QAAQ,CAAC,6BAA6B,CAAC,GAAG,sBAAsB,CAarH"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ModifierSlot, VertexDisplaceModifierKind } from '@flighthq/types';
|
|
2
|
+
// Builds a VertexDisplaceModifier (slot: Vertex) — the one built-in VERTEX-stage modifier, displacing
|
|
3
|
+
// each vertex along its normal (or a fixed `axis`) before the model transform. `Sine` is a procedural
|
|
4
|
+
// traveling wave animated by the shading tier's per-frame `time` (using `frequency` default 1, `speed`
|
|
5
|
+
// default 1, `direction` default +X); `HeightMap` reads the amount from `map`'s red channel. `axis`,
|
|
6
|
+
// `map`, and `direction` are plain value pairs copied by reference only when provided.
|
|
7
|
+
export function createVertexDisplaceModifier(options) {
|
|
8
|
+
const modifier = {
|
|
9
|
+
kind: VertexDisplaceModifierKind,
|
|
10
|
+
slot: ModifierSlot.Vertex,
|
|
11
|
+
source: options.source,
|
|
12
|
+
amplitude: options.amplitude,
|
|
13
|
+
frequency: options.frequency ?? 1,
|
|
14
|
+
speed: options.speed ?? 1,
|
|
15
|
+
direction: options.direction ?? DEFAULT_DIRECTION,
|
|
16
|
+
};
|
|
17
|
+
if (options.axis !== undefined)
|
|
18
|
+
modifier.axis = options.axis;
|
|
19
|
+
if (options.map !== undefined)
|
|
20
|
+
modifier.map = options.map;
|
|
21
|
+
return modifier;
|
|
22
|
+
}
|
|
23
|
+
const DEFAULT_DIRECTION = { x: 1, y: 0, z: 0 };
|
|
24
|
+
//# sourceMappingURL=createVertexDisplaceModifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createVertexDisplaceModifier.js","sourceRoot":"","sources":["../src/createVertexDisplaceModifier.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,0BAA0B,EAAE,MAAM,iBAAiB,CAAC;AAiB3E,sGAAsG;AACtG,sGAAsG;AACtG,uGAAuG;AACvG,qGAAqG;AACrG,uFAAuF;AACvF,MAAM,UAAU,4BAA4B,CAAC,OAAgD;IAC3F,MAAM,QAAQ,GAA2B;QACvC,IAAI,EAAE,0BAA0B;QAChC,IAAI,EAAE,YAAY,CAAC,MAAM;QACzB,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,CAAC;QACjC,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,CAAC;QACzB,SAAS,EAAE,OAAO,CAAC,SAAS,IAAI,iBAAiB;KAClD,CAAC;IACF,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS;QAAE,QAAQ,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAC7D,IAAI,OAAO,CAAC,GAAG,KAAK,SAAS;QAAE,QAAQ,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;IAC1D,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,MAAM,iBAAiB,GAAgB,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Modifier } from '@flighthq/types';
|
|
2
|
+
import type { ModifierRegistry } from './modifierRegistry';
|
|
3
|
+
export declare function getModifierDefineKey(stack: readonly Modifier[], registry?: Readonly<ModifierRegistry>): string;
|
|
4
|
+
//# sourceMappingURL=getModifierDefineKey.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getModifierDefineKey.d.ts","sourceRoot":"","sources":["../src/getModifierDefineKey.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAmB3D,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,SAAS,QAAQ,EAAE,EAAE,QAAQ,CAAC,EAAE,QAAQ,CAAC,gBAAgB,CAAC,GAAG,MAAM,CAS9G"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { resolveModifier } from './modifierRegistry';
|
|
2
|
+
import { orderModifierStack } from './orderModifierStack';
|
|
3
|
+
// Produces the stable define-key for a modifier stack — the string the compile path caches compiled
|
|
4
|
+
// programs by, and the key that makes two materials with the same feature-set share one variant (and
|
|
5
|
+
// therefore batch). Two properties hold: it is INDEPENDENT of cross-slot authoring order (the stack
|
|
6
|
+
// is canonicalized via `orderModifierStack` first), and it captures every COMPILE-TIME variant of
|
|
7
|
+
// each modifier while ignoring uniform-fed values (color/strength change the key not at all). The
|
|
8
|
+
// latter comes from the registry: each modifier's registered `getDefineSignature` returns a token
|
|
9
|
+
// naming which optional, program-shaping features are present (a mask, a facing gate, a second
|
|
10
|
+
// layer), so an emissive-with-mask and a plain emissive get distinct keys and never collide in the
|
|
11
|
+
// program cache.
|
|
12
|
+
//
|
|
13
|
+
// Format: the ordered modifiers joined by `+`, each rendered as `<kind>` or `<kind>:<signature>`
|
|
14
|
+
// when its signature is non-empty — e.g. `AnimatedNormalModifier:1+EmissiveModifier:mg+RimModifier`.
|
|
15
|
+
// An empty stack yields `''` (the bare base program). Without a `registry`, or for a kind with no
|
|
16
|
+
// registered signature, the token is the bare `<kind>` (a coarser key that still distinguishes
|
|
17
|
+
// feature sets by kind, but not by per-kind compile-time variant — pass the registry for precision).
|
|
18
|
+
export function getModifierDefineKey(stack, registry) {
|
|
19
|
+
const ordered = orderModifierStack(stack);
|
|
20
|
+
let key = '';
|
|
21
|
+
for (const modifier of ordered) {
|
|
22
|
+
const signature = getDefineSignature(modifier, registry);
|
|
23
|
+
const token = signature.length > 0 ? `${modifier.kind}:${signature}` : modifier.kind;
|
|
24
|
+
key = key.length > 0 ? `${key}+${token}` : token;
|
|
25
|
+
}
|
|
26
|
+
return key;
|
|
27
|
+
}
|
|
28
|
+
function getDefineSignature(modifier, registry) {
|
|
29
|
+
if (registry === undefined)
|
|
30
|
+
return '';
|
|
31
|
+
const definition = resolveModifier(registry, modifier.kind);
|
|
32
|
+
if (definition === null || definition.getDefineSignature === undefined)
|
|
33
|
+
return '';
|
|
34
|
+
return definition.getDefineSignature(modifier);
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=getModifierDefineKey.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getModifierDefineKey.js","sourceRoot":"","sources":["../src/getModifierDefineKey.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,oGAAoG;AACpG,qGAAqG;AACrG,oGAAoG;AACpG,kGAAkG;AAClG,kGAAkG;AAClG,kGAAkG;AAClG,+FAA+F;AAC/F,mGAAmG;AACnG,iBAAiB;AACjB,EAAE;AACF,iGAAiG;AACjG,qGAAqG;AACrG,kGAAkG;AAClG,+FAA+F;AAC/F,qGAAqG;AACrG,MAAM,UAAU,oBAAoB,CAAC,KAA0B,EAAE,QAAqC;IACpG,MAAM,OAAO,GAAG,kBAAkB,CAAC,KAAK,CAAC,CAAC;IAC1C,IAAI,GAAG,GAAG,EAAE,CAAC;IACb,KAAK,MAAM,QAAQ,IAAI,OAAO,EAAE,CAAC;QAC/B,MAAM,SAAS,GAAG,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;QACzD,MAAM,KAAK,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,IAAI,IAAI,SAAS,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;QACrF,GAAG,GAAG,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC;IACnD,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,kBAAkB,CAAC,QAA4B,EAAE,QAAqC;IAC7F,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IACtC,MAAM,UAAU,GAAG,eAAe,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IAC5D,IAAI,UAAU,KAAK,IAAI,IAAI,UAAU,CAAC,kBAAkB,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IAClF,OAAO,UAAU,CAAC,kBAAkB,CAAC,QAAQ,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Modifier, ModifierKind } from '@flighthq/types';
|
|
2
|
+
import type { ModifierRegistry } from './modifierRegistry';
|
|
3
|
+
export declare function getUnregisteredModifierKinds(registry: Readonly<ModifierRegistry>, stack: readonly Modifier[]): readonly ModifierKind[];
|
|
4
|
+
//# sourceMappingURL=getUnregisteredModifierKinds.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUnregisteredModifierKinds.d.ts","sourceRoot":"","sources":["../src/getUnregisteredModifierKinds.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE9D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAO3D,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,QAAQ,CAAC,gBAAgB,CAAC,EACpC,KAAK,EAAE,SAAS,QAAQ,EAAE,GACzB,SAAS,YAAY,EAAE,CAQzB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { resolveModifier } from './modifierRegistry';
|
|
2
|
+
// Returns the kinds in `stack` that have no definition in `registry` — the modifiers the compile
|
|
3
|
+
// path cannot assemble. An empty array is the all-clear sentinel (no throw for the expected case of
|
|
4
|
+
// an unknown kind). Each unregistered kind appears once, in first-seen order, so a caller can report
|
|
5
|
+
// exactly which vendor kind is missing its `registerModifier` call.
|
|
6
|
+
export function getUnregisteredModifierKinds(registry, stack) {
|
|
7
|
+
const unregistered = [];
|
|
8
|
+
for (const modifier of stack) {
|
|
9
|
+
if (resolveModifier(registry, modifier.kind) !== null)
|
|
10
|
+
continue;
|
|
11
|
+
if (unregistered.includes(modifier.kind))
|
|
12
|
+
continue;
|
|
13
|
+
unregistered.push(modifier.kind);
|
|
14
|
+
}
|
|
15
|
+
return unregistered;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=getUnregisteredModifierKinds.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getUnregisteredModifierKinds.js","sourceRoot":"","sources":["../src/getUnregisteredModifierKinds.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,iGAAiG;AACjG,oGAAoG;AACpG,qGAAqG;AACrG,oEAAoE;AACpE,MAAM,UAAU,4BAA4B,CAC1C,QAAoC,EACpC,KAA0B;IAE1B,MAAM,YAAY,GAAmB,EAAE,CAAC;IACxC,KAAK,MAAM,QAAQ,IAAI,KAAK,EAAE,CAAC;QAC7B,IAAI,eAAe,CAAC,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,KAAK,IAAI;YAAE,SAAS;QAChE,IAAI,YAAY,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC;YAAE,SAAS;QACnD,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from './createAnimatedNormalModifier';
|
|
2
|
+
export * from './createDissolveModifier';
|
|
3
|
+
export * from './createEmissiveModifier';
|
|
4
|
+
export * from './createEnvReflectModifier';
|
|
5
|
+
export * from './createFogModifier';
|
|
6
|
+
export * from './createRimModifier';
|
|
7
|
+
export * from './createShadedMaterial';
|
|
8
|
+
export * from './createToonModifier';
|
|
9
|
+
export * from './createVertexDisplaceModifier';
|
|
10
|
+
export * from './getModifierDefineKey';
|
|
11
|
+
export * from './getUnregisteredModifierKinds';
|
|
12
|
+
export * from './isBuiltInModifierSlot';
|
|
13
|
+
export * from './isModifierStackValid';
|
|
14
|
+
export * from './modifierRegistry';
|
|
15
|
+
export * from './orderModifierStack';
|
|
16
|
+
export * from './registerBuiltInModifiers';
|
|
17
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from './createAnimatedNormalModifier';
|
|
2
|
+
export * from './createDissolveModifier';
|
|
3
|
+
export * from './createEmissiveModifier';
|
|
4
|
+
export * from './createEnvReflectModifier';
|
|
5
|
+
export * from './createFogModifier';
|
|
6
|
+
export * from './createRimModifier';
|
|
7
|
+
export * from './createShadedMaterial';
|
|
8
|
+
export * from './createToonModifier';
|
|
9
|
+
export * from './createVertexDisplaceModifier';
|
|
10
|
+
export * from './getModifierDefineKey';
|
|
11
|
+
export * from './getUnregisteredModifierKinds';
|
|
12
|
+
export * from './isBuiltInModifierSlot';
|
|
13
|
+
export * from './isModifierStackValid';
|
|
14
|
+
export * from './modifierRegistry';
|
|
15
|
+
export * from './orderModifierStack';
|
|
16
|
+
export * from './registerBuiltInModifiers';
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAC;AAC/C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,wBAAwB,CAAC;AACvC,cAAc,gCAAgC,CAAC;AAC/C,cAAc,yBAAyB,CAAC;AACxC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,4BAA4B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isBuiltInModifierSlot.d.ts","sourceRoot":"","sources":["../src/isBuiltInModifierSlot.ts"],"names":[],"mappings":"AAOA,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAE5D"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ModifierSlot } from '@flighthq/types';
|
|
2
|
+
// Returns true when `value` is one of the built-in slot names (Vertex/Normal/Diffuse/Specular/
|
|
3
|
+
// Emissive/Effect). A sentinel-returning guard, not a throw: it reports membership in the canonical
|
|
4
|
+
// built-in taxonomy so a caller can distinguish a known built-in slot from a reserved (Ambient/Shadow)
|
|
5
|
+
// or vendor-prefixed one. `ModifierSlot` is an open family (reserved and vendor slots are valid to
|
|
6
|
+
// author), so this predicate is deliberately about BUILT-IN membership, not slot-hood in general.
|
|
7
|
+
export function isBuiltInModifierSlot(value) {
|
|
8
|
+
return BUILT_IN_SLOTS.has(value);
|
|
9
|
+
}
|
|
10
|
+
const BUILT_IN_SLOTS = new Set([
|
|
11
|
+
ModifierSlot.Diffuse,
|
|
12
|
+
ModifierSlot.Effect,
|
|
13
|
+
ModifierSlot.Emissive,
|
|
14
|
+
ModifierSlot.Normal,
|
|
15
|
+
ModifierSlot.Specular,
|
|
16
|
+
ModifierSlot.Vertex,
|
|
17
|
+
]);
|
|
18
|
+
//# sourceMappingURL=isBuiltInModifierSlot.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isBuiltInModifierSlot.js","sourceRoot":"","sources":["../src/isBuiltInModifierSlot.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,+FAA+F;AAC/F,oGAAoG;AACpG,uGAAuG;AACvG,mGAAmG;AACnG,kGAAkG;AAClG,MAAM,UAAU,qBAAqB,CAAC,KAAa;IACjD,OAAO,cAAc,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;AACnC,CAAC;AAED,MAAM,cAAc,GAAG,IAAI,GAAG,CAAS;IACrC,YAAY,CAAC,OAAO;IACpB,YAAY,CAAC,MAAM;IACnB,YAAY,CAAC,QAAQ;IACrB,YAAY,CAAC,MAAM;IACnB,YAAY,CAAC,QAAQ;IACrB,YAAY,CAAC,MAAM;CACpB,CAAC,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { Modifier } from '@flighthq/types';
|
|
2
|
+
import type { ModifierRegistry } from './modifierRegistry';
|
|
3
|
+
export declare function isModifierStackValid(registry: Readonly<ModifierRegistry>, stack: readonly Modifier[]): boolean;
|
|
4
|
+
//# sourceMappingURL=isModifierStackValid.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isModifierStackValid.d.ts","sourceRoot":"","sources":["../src/isModifierStackValid.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAGhD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAK3D,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,CAAC,gBAAgB,CAAC,EAAE,KAAK,EAAE,SAAS,QAAQ,EAAE,GAAG,OAAO,CAE9G"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { getUnregisteredModifierKinds } from './getUnregisteredModifierKinds';
|
|
2
|
+
// Returns true when every modifier in `stack` has a definition in `registry` — the boolean the
|
|
3
|
+
// compile path checks before assembling a program. An empty stack is valid (it compiles to the bare
|
|
4
|
+
// base). The plain-data companion is `getUnregisteredModifierKinds`, which names which kinds fail.
|
|
5
|
+
export function isModifierStackValid(registry, stack) {
|
|
6
|
+
return getUnregisteredModifierKinds(registry, stack).length === 0;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=isModifierStackValid.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isModifierStackValid.js","sourceRoot":"","sources":["../src/isModifierStackValid.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,4BAA4B,EAAE,MAAM,gCAAgC,CAAC;AAG9E,+FAA+F;AAC/F,oGAAoG;AACpG,mGAAmG;AACnG,MAAM,UAAU,oBAAoB,CAAC,QAAoC,EAAE,KAA0B;IACnG,OAAO,4BAA4B,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,MAAM,KAAK,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Modifier, ModifierKind, ModifierSlot } from '@flighthq/types';
|
|
2
|
+
export interface ModifierDefinition {
|
|
3
|
+
kind: ModifierKind;
|
|
4
|
+
slot: ModifierSlot;
|
|
5
|
+
getDefineSignature?: (modifier: Readonly<Modifier>) => string;
|
|
6
|
+
}
|
|
7
|
+
export interface ModifierRegistry {
|
|
8
|
+
definitions: Map<ModifierKind, ModifierDefinition>;
|
|
9
|
+
}
|
|
10
|
+
export declare function createModifierRegistry(): ModifierRegistry;
|
|
11
|
+
export declare function registerModifier(registry: Readonly<ModifierRegistry>, definition: Readonly<ModifierDefinition>): void;
|
|
12
|
+
export declare function resolveModifier(registry: Readonly<ModifierRegistry>, kind: ModifierKind): ModifierDefinition | null;
|
|
13
|
+
//# sourceMappingURL=modifierRegistry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modifierRegistry.d.ts","sourceRoot":"","sources":["../src/modifierRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAa5E,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,YAAY,CAAC;IACnB,IAAI,EAAE,YAAY,CAAC;IACnB,kBAAkB,CAAC,EAAE,CAAC,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,KAAK,MAAM,CAAC;CAC/D;AAOD,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,GAAG,CAAC,YAAY,EAAE,kBAAkB,CAAC,CAAC;CACpD;AAID,wBAAgB,sBAAsB,IAAI,gBAAgB,CAEzD;AAMD,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,CAAC,gBAAgB,CAAC,EAAE,UAAU,EAAE,QAAQ,CAAC,kBAAkB,CAAC,GAAG,IAAI,CAErH;AAID,wBAAgB,eAAe,CAAC,QAAQ,EAAE,QAAQ,CAAC,gBAAgB,CAAC,EAAE,IAAI,EAAE,YAAY,GAAG,kBAAkB,GAAG,IAAI,CAEnH"}
|