@casmo/tree.js 0.3.0 → 0.5.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/README.md +775 -4
- package/dist/effects/custom.d.ts +62 -0
- package/dist/effects/custom.d.ts.map +1 -0
- package/dist/effects/effects.d.ts +92 -6
- package/dist/effects/effects.d.ts.map +1 -1
- package/dist/effects/glow.d.ts +5 -0
- package/dist/effects/glow.d.ts.map +1 -1
- package/dist/effects/grade.d.ts +3 -0
- package/dist/effects/grade.d.ts.map +1 -1
- package/dist/effects/highlight.d.ts +35 -0
- package/dist/effects/highlight.d.ts.map +1 -0
- package/dist/effects/index.d.ts +7 -1
- package/dist/effects/index.d.ts.map +1 -1
- package/dist/effects/inner-lines.d.ts +39 -0
- package/dist/effects/inner-lines.d.ts.map +1 -0
- package/dist/effects/live.d.ts +12 -0
- package/dist/effects/live.d.ts.map +1 -0
- package/dist/effects/mask.d.ts +32 -12
- package/dist/effects/mask.d.ts.map +1 -1
- package/dist/effects/outline.d.ts +12 -0
- package/dist/effects/outline.d.ts.map +1 -1
- package/dist/effects/pass.d.ts +27 -0
- package/dist/effects/pass.d.ts.map +1 -0
- package/dist/effects/screen.d.ts +31 -0
- package/dist/effects/screen.d.ts.map +1 -0
- package/dist/effects/suggested.d.ts +5 -0
- package/dist/effects/suggested.d.ts.map +1 -1
- package/dist/effects/tree-id.d.ts +50 -0
- package/dist/effects/tree-id.d.ts.map +1 -0
- package/dist/effects-qHx_8Dlk.js +1052 -0
- package/dist/effects-qHx_8Dlk.js.map +1 -0
- package/dist/effects.js +3 -249
- package/dist/forest/Forest.d.ts +82 -4
- package/dist/forest/Forest.d.ts.map +1 -1
- package/dist/forest/forest-lod.d.ts +70 -0
- package/dist/forest/forest-lod.d.ts.map +1 -0
- package/dist/forest/impostor-material.d.ts +106 -0
- package/dist/forest/impostor-material.d.ts.map +1 -0
- package/dist/forest/impostor-season.d.ts +13 -0
- package/dist/forest/impostor-season.d.ts.map +1 -0
- package/dist/forest/impostor.d.ts +105 -0
- package/dist/forest/impostor.d.ts.map +1 -0
- package/dist/forest/index.d.ts +1 -0
- package/dist/forest/index.d.ts.map +1 -1
- package/dist/forest/levels.d.ts +144 -0
- package/dist/forest/levels.d.ts.map +1 -0
- package/dist/forest/lod.d.ts +106 -0
- package/dist/forest/lod.d.ts.map +1 -0
- package/dist/forest/nodes.d.ts +42 -1
- package/dist/forest/nodes.d.ts.map +1 -1
- package/dist/forest/octahedral.d.ts +33 -0
- package/dist/forest/octahedral.d.ts.map +1 -0
- package/dist/{forest-ChEaWJrf.js → forest-CM5DrklM.js} +1727 -340
- package/dist/forest-CM5DrklM.js.map +1 -0
- package/dist/generator/fruit.d.ts +2 -0
- package/dist/generator/fruit.d.ts.map +1 -1
- package/dist/generator/index.d.ts +1 -0
- package/dist/generator/index.d.ts.map +1 -1
- package/dist/generator/light.d.ts +36 -0
- package/dist/generator/light.d.ts.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/materials/crown-nodes.d.ts +5 -0
- package/dist/materials/crown-nodes.d.ts.map +1 -1
- package/dist/materials/leaf-translucency-model.d.ts +6 -1
- package/dist/materials/leaf-translucency-model.d.ts.map +1 -1
- package/dist/materials/material-features.d.ts +12 -0
- package/dist/materials/material-features.d.ts.map +1 -1
- package/dist/materials/shader-hooks.d.ts +155 -0
- package/dist/materials/shader-hooks.d.ts.map +1 -0
- package/dist/motion-Qd7xjeZM.js +276 -0
- package/dist/motion-Qd7xjeZM.js.map +1 -0
- package/dist/nodes-DxgTyF9B.js +436 -0
- package/dist/nodes-DxgTyF9B.js.map +1 -0
- package/dist/react/Forest.d.ts +17 -3
- package/dist/react/Forest.d.ts.map +1 -1
- package/dist/react/ScenePipeline.d.ts +63 -0
- package/dist/react/ScenePipeline.d.ts.map +1 -0
- package/dist/react/SceneShaderHooks.d.ts +25 -0
- package/dist/react/SceneShaderHooks.d.ts.map +1 -0
- package/dist/react/Tree.d.ts +9 -2
- package/dist/react/Tree.d.ts.map +1 -1
- package/dist/react/Weather.d.ts +45 -0
- package/dist/react/Weather.d.ts.map +1 -0
- package/dist/react/Wind.d.ts +12 -1
- package/dist/react/Wind.d.ts.map +1 -1
- package/dist/react/index.d.ts +7 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react.js +347 -10
- package/dist/react.js.map +1 -1
- package/dist/renderer/index.d.ts +6 -0
- package/dist/renderer/index.d.ts.map +1 -1
- package/dist/scene/antialias.d.ts +35 -0
- package/dist/scene/antialias.d.ts.map +1 -0
- package/dist/scene/ao.d.ts +46 -0
- package/dist/scene/ao.d.ts.map +1 -0
- package/dist/scene/bloom.d.ts +19 -0
- package/dist/scene/bloom.d.ts.map +1 -0
- package/dist/scene/fog.d.ts +49 -0
- package/dist/scene/fog.d.ts.map +1 -0
- package/dist/scene/godrays.d.ts +37 -0
- package/dist/scene/godrays.d.ts.map +1 -0
- package/dist/scene/index.d.ts +14 -0
- package/dist/scene/index.d.ts.map +1 -0
- package/dist/scene/motion-blur.d.ts +23 -0
- package/dist/scene/motion-blur.d.ts.map +1 -0
- package/dist/scene/pipeline.d.ts +109 -0
- package/dist/scene/pipeline.d.ts.map +1 -0
- package/dist/scene/settings.d.ts +36 -0
- package/dist/scene/settings.d.ts.map +1 -0
- package/dist/scene/stack.d.ts +25 -0
- package/dist/scene/stack.d.ts.map +1 -0
- package/dist/scene/stage.d.ts +52 -0
- package/dist/scene/stage.d.ts.map +1 -0
- package/dist/scene/suggested.d.ts +12 -0
- package/dist/scene/suggested.d.ts.map +1 -0
- package/dist/scene/tone-mapping.d.ts +20 -0
- package/dist/scene/tone-mapping.d.ts.map +1 -0
- package/dist/scene/velocity.d.ts +34 -0
- package/dist/scene/velocity.d.ts.map +1 -0
- package/dist/scene.js +889 -0
- package/dist/scene.js.map +1 -0
- package/dist/season/nodes.d.ts +13 -0
- package/dist/season/nodes.d.ts.map +1 -1
- package/dist/shader-hooks-BFRtlWGI.js +275 -0
- package/dist/shader-hooks-BFRtlWGI.js.map +1 -0
- package/dist/tree/Tree.d.ts +8 -3
- package/dist/tree/Tree.d.ts.map +1 -1
- package/dist/tree/index.d.ts.map +1 -1
- package/dist/weather/index.d.ts +3 -0
- package/dist/weather/index.d.ts.map +1 -0
- package/dist/weather/shared.d.ts +43 -0
- package/dist/weather/shared.d.ts.map +1 -0
- package/dist/weather/snow.d.ts +87 -0
- package/dist/weather/snow.d.ts.map +1 -0
- package/dist/weather/wetness.d.ts +75 -0
- package/dist/weather/wetness.d.ts.map +1 -0
- package/dist/weather.js +288 -0
- package/dist/weather.js.map +1 -0
- package/dist/wind/Wind.d.ts +100 -5
- package/dist/wind/Wind.d.ts.map +1 -1
- package/dist/wind/burst.d.ts +28 -0
- package/dist/wind/burst.d.ts.map +1 -0
- package/dist/wind/index.d.ts +3 -2
- package/dist/wind/index.d.ts.map +1 -1
- package/dist/wind/motion.d.ts +30 -0
- package/dist/wind/motion.d.ts.map +1 -0
- package/dist/wind/node.d.ts +17 -3
- package/dist/wind/node.d.ts.map +1 -1
- package/package.json +9 -1
- package/dist/effects.js.map +0 -1
- package/dist/forest-ChEaWJrf.js.map +0 -1
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { UniformNode } from 'three/webgpu';
|
|
2
|
+
import { type TreePart } from '../effects/mask';
|
|
3
|
+
/** The options of a scene-wide weather amount ({@link WeatherAmount}). */
|
|
4
|
+
export interface WeatherAmountOptions {
|
|
5
|
+
/** 0 (none, default) .. 1 (full). */
|
|
6
|
+
amount?: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* A scene-wide weather amount (0..1) that ready-made hooks follow, shared like a `Wind`: changing it only
|
|
10
|
+
* writes a uniform (no recompile). The base of `Snow` and `Wetness`.
|
|
11
|
+
*/
|
|
12
|
+
export declare abstract class WeatherAmount {
|
|
13
|
+
private readonly label;
|
|
14
|
+
/** The shared TSL uniforms the hooks read. Write through the setters, not here. */
|
|
15
|
+
readonly uniforms: {
|
|
16
|
+
readonly amount: UniformNode<'float', number>;
|
|
17
|
+
};
|
|
18
|
+
/** `label`: how errors name the amount, e.g. 'Snow amount'. */
|
|
19
|
+
protected constructor(label: string, options: WeatherAmountOptions);
|
|
20
|
+
get amount(): number;
|
|
21
|
+
set amount(value: number);
|
|
22
|
+
/** Sets the amount; returns this. */
|
|
23
|
+
set(options: WeatherAmountOptions): this;
|
|
24
|
+
}
|
|
25
|
+
/** `value` if it is in 0..1; throws a RangeError naming `label` otherwise. */
|
|
26
|
+
export declare function unitValue(label: string, value: number): number;
|
|
27
|
+
/** `value` if it is an angle in 0..`max` degrees; throws a RangeError naming `label` otherwise. */
|
|
28
|
+
export declare function degreesValue(label: string, value: number, max: number): number;
|
|
29
|
+
/** `value` if it is a finite number >= 0; throws a RangeError naming `label` otherwise. */
|
|
30
|
+
export declare function softnessValue(label: string, value: number): number;
|
|
31
|
+
/** `current` with the per-part strengths of `next` (each checked to be 0..1, `label` names them in errors). */
|
|
32
|
+
export declare function strengthsWith(label: string, current: Record<TreePart, number>, next: Partial<Record<TreePart, number>> | undefined): Record<TreePart, number>;
|
|
33
|
+
/**
|
|
34
|
+
* The world normal's y range of a slope setting, shared by Snow Cover and Wetness: `slope` is how far a
|
|
35
|
+
* surface may tilt from level (its normal from straight up, in degrees) and still take any; `softness`
|
|
36
|
+
* the degrees below `slope` over which it fades in. `none`: the normal's y at `slope` (none at or beyond
|
|
37
|
+
* it); `full`: at `slope - softness` (full from there up), always above `none`.
|
|
38
|
+
*/
|
|
39
|
+
export declare function slopeRange(slope: number, softness: number): {
|
|
40
|
+
none: number;
|
|
41
|
+
full: number;
|
|
42
|
+
};
|
|
43
|
+
//# sourceMappingURL=shared.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shared.d.ts","sourceRoot":"","sources":["../../src/weather/shared.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,E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wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAI1F"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { Color, type ColorRepresentation, type Node } from 'three/webgpu';
|
|
2
|
+
import { type TreePart } from '../effects/mask';
|
|
3
|
+
import { type TreeShaderHook, type TreeShaderInput, type TreeShaderOutput } from '../materials/shader-hooks';
|
|
4
|
+
import { WeatherAmount } from './shared';
|
|
5
|
+
export interface SnowOptions {
|
|
6
|
+
/** How much snow lies on the trees: 0 = none (default), 1 = full cover. */
|
|
7
|
+
amount?: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A snow amount (0..1) that every {@link snowCoverHooks} hook following it whitens trees by, like a `Wind`
|
|
11
|
+
* is shared by the trees swaying with it. Changing it only writes a uniform (no recompile). Snow Cover
|
|
12
|
+
* follows {@link sceneSnow} unless it is given another one.
|
|
13
|
+
*/
|
|
14
|
+
export declare class Snow extends WeatherAmount {
|
|
15
|
+
constructor(options?: SnowOptions);
|
|
16
|
+
}
|
|
17
|
+
/** The scene-wide snow amount every Snow Cover follows by default. */
|
|
18
|
+
export declare const sceneSnow: Snow;
|
|
19
|
+
/** How Snow Cover ({@link snowCoverHooks}) looks; every setting is live (a uniform write, no rebuild). */
|
|
20
|
+
export interface SnowCoverSettings {
|
|
21
|
+
/** Snow colour (sRGB, like any three.js colour). Default `#f4f8ff`, a slightly blue white. */
|
|
22
|
+
color?: ColorRepresentation;
|
|
23
|
+
/**
|
|
24
|
+
* The steepest surface that still holds snow, in degrees from level (0..90; the same as how far its
|
|
25
|
+
* normal is from facing straight up), as Wetness's `slope`. Default 60.
|
|
26
|
+
*/
|
|
27
|
+
slope?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Degrees (>= 0) below `slope` over which the snow fades out towards it: full up to `slope - softness`,
|
|
30
|
+
* none from `slope` on, as Wetness's `softness`. Default 25; 0 is a hard edge.
|
|
31
|
+
*/
|
|
32
|
+
softness?: number;
|
|
33
|
+
/** How much snow each tree part takes (0..1). Default 1 for bark, leaves and fruit. */
|
|
34
|
+
strength?: Partial<Record<TreePart, number>>;
|
|
35
|
+
}
|
|
36
|
+
/** The settings of a {@link snowCoverHooks} hook, all given. */
|
|
37
|
+
export interface SnowCoverLook {
|
|
38
|
+
color: Color;
|
|
39
|
+
slope: number;
|
|
40
|
+
softness: number;
|
|
41
|
+
strength: Record<TreePart, number>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The ready-made Snow Cover hooks (GLOSSARY: Snow Cover) for bark, leaves and fruit: a set of Tree Shader
|
|
45
|
+
* Hooks to hand to a Tree, a Forest, `setSceneShaderHooks` or `stackShaderHooks`, with live settings.
|
|
46
|
+
*/
|
|
47
|
+
export interface SnowCoverHooks {
|
|
48
|
+
readonly bark: TreeShaderHook;
|
|
49
|
+
readonly leaves: TreeShaderHook;
|
|
50
|
+
readonly fruit: TreeShaderHook;
|
|
51
|
+
/** The snow amount the hooks follow. */
|
|
52
|
+
readonly snow: Snow;
|
|
53
|
+
/** The current settings (a copy). */
|
|
54
|
+
readonly settings: SnowCoverLook;
|
|
55
|
+
/** Changes settings live (uniform writes, no rebuild); returns this. */
|
|
56
|
+
set(settings: SnowCoverSettings): this;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Makes the ready-made Snow Cover hooks: they whiten the surfaces of trees that face up by the amount of
|
|
60
|
+
* `snow` (default {@link sceneSnow}), drawn to suit the tree's Style: hard flat caps on `'flat'`
|
|
61
|
+
* (low-poly), toon bands on `'toon'` (stylized), soft lit snow with a slight sparkle on `'standard'`
|
|
62
|
+
* (realistic). Snow is read from the world normal after Wind, so it follows swaying branches and lies on
|
|
63
|
+
* bare winter branches when the leaves are gone; undersides stay bare. With the amount at 0 the trees look
|
|
64
|
+
* exactly as without the hooks. They run before the app's own hooks in every stack. A game that wants its
|
|
65
|
+
* own snow can start from {@link snowCoverShading}.
|
|
66
|
+
*/
|
|
67
|
+
export declare function snowCoverHooks(settings?: SnowCoverSettings & {
|
|
68
|
+
snow?: Snow;
|
|
69
|
+
}): SnowCoverHooks;
|
|
70
|
+
/** The settings {@link snowCoverShading} draws with, as TSL nodes (uniforms, so they can change live). */
|
|
71
|
+
export interface SnowCoverShadingSettings {
|
|
72
|
+
/** How much snow (0..1): the snow amount times the part's strength. */
|
|
73
|
+
amount: Node<'float'>;
|
|
74
|
+
/** Snow colour (linear rgb). */
|
|
75
|
+
color: Node<'vec3'>;
|
|
76
|
+
/** The world normal's y at or below which a surface stays bare (the cosine of the steepest slope that holds snow). */
|
|
77
|
+
bare: Node<'float'>;
|
|
78
|
+
/** The world normal's y from which on a surface is fully covered (> `bare`). */
|
|
79
|
+
covered: Node<'float'>;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The shading of Snow Cover, as a plain Tree Shader Hook body: a starting point for a game's own snow
|
|
83
|
+
* (`const mySnow: TreeShaderHook = (input) => snowCoverShading(input, { ... })`). It only uses the hook's
|
|
84
|
+
* inputs and the settings given.
|
|
85
|
+
*/
|
|
86
|
+
export declare function snowCoverShading(input: TreeShaderInput, settings: SnowCoverShadingSettings): TreeShaderOutput;
|
|
87
|
+
//# sourceMappingURL=snow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snow.d.ts","sourceRoot":"","sources":["../../src/weather/snow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,KAAK,mBAAmB,EAAE,KAAK,IAAI,EAAE,MAAM,cAAc,CAAC;AAE1E,OAAO,EAAc,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAuB,KAAK,cAAc,EAAE,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAClI,OAAO,EAA0D,aAAa,EAAE,MAAM,U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AA0G;AAC1G,MAAM,WAAW,wBAAwB;IACvC,uEAAuE;IACvE,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACtB,gCAAgC;IAChC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACpB,sHAAsH;IACtH,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACpB,gFAAgF;IAChF,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;CACxB;AAID;;;;GAIG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,wBAAwB,GAAG,gBAAgB,CA8B7G"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Color, type ColorRepresentation } from 'three/webgpu';
|
|
2
|
+
import { type TreePart } from '../effects/mask';
|
|
3
|
+
import { type TreeShaderHook } from '../materials/shader-hooks';
|
|
4
|
+
import { WeatherAmount } from './shared';
|
|
5
|
+
export interface WetnessOptions {
|
|
6
|
+
/** How wet the trees are: 0 = dry (default), 1 = soaked. */
|
|
7
|
+
amount?: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A scene-wide wetness amount (0..1) that every {@link wetnessHooks} hook reading it follows, as after
|
|
11
|
+
* rain. Shared like `sceneWind`: hooks use {@link sceneWetness} unless given another one. Changing it only
|
|
12
|
+
* writes a uniform (no recompile).
|
|
13
|
+
*/
|
|
14
|
+
export declare class Wetness extends WeatherAmount {
|
|
15
|
+
constructor(options?: WetnessOptions);
|
|
16
|
+
}
|
|
17
|
+
/** The scene-wide wetness every Wetness hook follows by default. */
|
|
18
|
+
export declare const sceneWetness: Wetness;
|
|
19
|
+
/** How a {@link wetnessHooks} hook looks; every setting is live (a uniform write, no rebuild). */
|
|
20
|
+
export interface WetnessSettings {
|
|
21
|
+
/** The tint wet surfaces take on (multiplied into their colour). Default a cool grey, `#dfe6ee`. */
|
|
22
|
+
color?: ColorRepresentation;
|
|
23
|
+
/**
|
|
24
|
+
* The steepest surface that still gets wet, in degrees from level (the same as how far its normal is
|
|
25
|
+
* from facing straight up), as Snow Cover's `slope`, but up to 180 (facing straight down): sides and
|
|
26
|
+
* undersides get wet too. Default 140 (only surfaces facing well down stay dry).
|
|
27
|
+
*/
|
|
28
|
+
slope?: number;
|
|
29
|
+
/**
|
|
30
|
+
* Degrees (>= 0) below `slope` over which wetness fades out towards it: fully wet up to
|
|
31
|
+
* `slope - softness`, dry from `slope` on, as Snow Cover's `softness`. Default 60; 0 is a hard edge.
|
|
32
|
+
*/
|
|
33
|
+
softness?: number;
|
|
34
|
+
/** How much each tree part takes (0..1). Default bark 1, leaves 0.8, fruit 0.5. */
|
|
35
|
+
strength?: Partial<Record<TreePart, number>>;
|
|
36
|
+
/** How much darker a soaked surface gets (0..1). Default 0.4. */
|
|
37
|
+
darkening?: number;
|
|
38
|
+
/** How much a soaked surface's roughness drops, so it shines (0..1). Default 0.6. */
|
|
39
|
+
sheen?: number;
|
|
40
|
+
}
|
|
41
|
+
/** The settings of a {@link wetnessHooks} hook, all given. */
|
|
42
|
+
export interface WetnessLook {
|
|
43
|
+
color: Color;
|
|
44
|
+
slope: number;
|
|
45
|
+
softness: number;
|
|
46
|
+
strength: Record<TreePart, number>;
|
|
47
|
+
darkening: number;
|
|
48
|
+
sheen: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* The ready-made Wetness hooks (GLOSSARY: Wetness) for bark, leaves and fruit: a set of Tree Shader Hooks
|
|
52
|
+
* to hand to a Tree, a Forest, `setSceneShaderHooks` or `stackShaderHooks`, with live settings.
|
|
53
|
+
*/
|
|
54
|
+
export interface WetnessHooks {
|
|
55
|
+
readonly bark: TreeShaderHook;
|
|
56
|
+
readonly leaves: TreeShaderHook;
|
|
57
|
+
readonly fruit: TreeShaderHook;
|
|
58
|
+
/** The amount the hooks follow. */
|
|
59
|
+
readonly wetness: Wetness;
|
|
60
|
+
/** The current settings (a copy). */
|
|
61
|
+
readonly settings: WetnessLook;
|
|
62
|
+
/** Changes settings live (uniform writes, no rebuild); returns this. */
|
|
63
|
+
set(settings: WetnessSettings): this;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Makes the ready-made Wetness hooks: trees darken and get a sheen (a lower roughness) by the amount of
|
|
67
|
+
* `wetness` (default {@link sceneWetness}), most on surfaces that face up, drawn to suit the Style:
|
|
68
|
+
* smooth on `'standard'` (realistic), whole facets on `'flat'` (low-poly), and in toon bands with a light
|
|
69
|
+
* glint band on top on `'toon'` (stylized; its lighting has no specular). With the amount at 0 the trees
|
|
70
|
+
* look as without the hooks. They run before the app's own hooks in every stack.
|
|
71
|
+
*/
|
|
72
|
+
export declare function wetnessHooks(settings?: WetnessSettings & {
|
|
73
|
+
wetness?: Wetness;
|
|
74
|
+
}): WetnessHooks;
|
|
75
|
+
//# sourceMappingURL=wetness.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wetness.d.ts","sourceRoot":"","sources":["../../src/weather/wetness.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,KAAK,mBAAmB,EAAa,MAAM,cAAc,CAAC;AAC1E,OAAO,EAAc,KAAK,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAuB,KAAK,cAAc,EAAwB,MAAM,2BAA2B,CAAC;AAC3G,OAAO,EAAqE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE5G,MAAM,WAAW,cAAc;IAC7B,4DAA4D;IAC5D,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;GAIG;AACH,qBAAa,OAAQ,SAAQ,aAAa;gBAC5B,OAAO,GAAE,cAAmB;CAGzC;AAED,oEAAoE;AACpE,eAAO,MAAM,YAAY,SAAgB,CAAC;AAE1C,kGAAkG;AAClG,MAAM,WAAW,eAAe;IAC9B,oGAAoG;IACpG,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,mFAAmF;IACnF,QAAQ,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;IAC7C,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,qFAAqF;IACrF,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,8DAA8D;AAC9D,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,KAAK,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IACnC,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;GAGG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,cAAc,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,QAAQ,CAAC,KAAK,EAAE,cAAc,CAAC;IAC/B,mCAAmC;IACnC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,qCAAqC;IACrC,QAAQ,CAAC,QAAQ,EAAE,WAAW,CAAC;IAC/B,wEAAwE;IACxE,GAAG,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI,CAAC;CACtC;AAWD;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,QAAQ,GAAE,eAAe,GAAG;IAAE,OAAO,CAAC,EAAE,OAAO,CAAA;CAAO,GAAG,YAAY,CA4DjG"}
|
package/dist/weather.js
ADDED
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import { d as TREE_PARTS } from "./motion-Qd7xjeZM.js";
|
|
2
|
+
import { a as readyMadeShaderHook } from "./shader-hooks-BFRtlWGI.js";
|
|
3
|
+
import { Color } from "three/webgpu";
|
|
4
|
+
import { cameraPosition, float, hash, mix, smoothstep, step, uniform } from "three/tsl";
|
|
5
|
+
// src/weather/shared.ts
|
|
6
|
+
/**
|
|
7
|
+
* A scene-wide weather amount (0..1) that ready-made hooks follow, shared like a `Wind`: changing it only
|
|
8
|
+
* writes a uniform (no recompile). The base of `Snow` and `Wetness`.
|
|
9
|
+
*/
|
|
10
|
+
var WeatherAmount = class {
|
|
11
|
+
label;
|
|
12
|
+
/** The shared TSL uniforms the hooks read. Write through the setters, not here. */
|
|
13
|
+
uniforms;
|
|
14
|
+
/** `label`: how errors name the amount, e.g. 'Snow amount'. */
|
|
15
|
+
constructor(label, options) {
|
|
16
|
+
this.label = label;
|
|
17
|
+
this.uniforms = { amount: uniform(0) };
|
|
18
|
+
this.set(options);
|
|
19
|
+
}
|
|
20
|
+
get amount() {
|
|
21
|
+
return this.uniforms.amount.value;
|
|
22
|
+
}
|
|
23
|
+
set amount(value) {
|
|
24
|
+
this.uniforms.amount.value = unitValue(this.label, value);
|
|
25
|
+
}
|
|
26
|
+
/** Sets the amount; returns this. */
|
|
27
|
+
set(options) {
|
|
28
|
+
if (options.amount !== void 0) this.amount = options.amount;
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
/** `value` if it is in 0..1; throws a RangeError naming `label` otherwise. */
|
|
33
|
+
function unitValue(label, value) {
|
|
34
|
+
if (!(value >= 0 && value <= 1)) throw new RangeError(`${label} must be a number in 0..1, got ${value}`);
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
/** `value` if it is an angle in 0..`max` degrees; throws a RangeError naming `label` otherwise. */
|
|
38
|
+
function degreesValue(label, value, max) {
|
|
39
|
+
if (!(value >= 0 && value <= max)) throw new RangeError(`${label} must be 0..${max} degrees, got ${value}`);
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
42
|
+
/** `value` if it is a finite number >= 0; throws a RangeError naming `label` otherwise. */
|
|
43
|
+
function softnessValue(label, value) {
|
|
44
|
+
if (!(value >= 0 && Number.isFinite(value))) throw new RangeError(`${label} must be a finite number >= 0, got ${value}`);
|
|
45
|
+
return value;
|
|
46
|
+
}
|
|
47
|
+
/** `current` with the per-part strengths of `next` (each checked to be 0..1, `label` names them in errors). */
|
|
48
|
+
function strengthsWith(label, current, next) {
|
|
49
|
+
const strength = { ...current };
|
|
50
|
+
for (const part of TREE_PARTS) {
|
|
51
|
+
const value = next?.[part];
|
|
52
|
+
if (value !== void 0) strength[part] = unitValue(`${label} ${part} strength`, value);
|
|
53
|
+
}
|
|
54
|
+
return strength;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The world normal's y range of a slope setting, shared by Snow Cover and Wetness: `slope` is how far a
|
|
58
|
+
* surface may tilt from level (its normal from straight up, in degrees) and still take any; `softness`
|
|
59
|
+
* the degrees below `slope` over which it fades in. `none`: the normal's y at `slope` (none at or beyond
|
|
60
|
+
* it); `full`: at `slope - softness` (full from there up), always above `none`.
|
|
61
|
+
*/
|
|
62
|
+
function slopeRange(slope, softness) {
|
|
63
|
+
const cosOf = (degrees) => Math.cos(Math.min(180, Math.max(0, degrees)) * Math.PI / 180);
|
|
64
|
+
const none = cosOf(slope);
|
|
65
|
+
return {
|
|
66
|
+
none,
|
|
67
|
+
full: Math.max(cosOf(slope - softness), none + 1e-4)
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
// src/weather/wetness.ts
|
|
71
|
+
/**
|
|
72
|
+
* A scene-wide wetness amount (0..1) that every {@link wetnessHooks} hook reading it follows, as after
|
|
73
|
+
* rain. Shared like `sceneWind`: hooks use {@link sceneWetness} unless given another one. Changing it only
|
|
74
|
+
* writes a uniform (no recompile).
|
|
75
|
+
*/
|
|
76
|
+
var Wetness = class extends WeatherAmount {
|
|
77
|
+
constructor(options = {}) {
|
|
78
|
+
super("Wetness amount", options);
|
|
79
|
+
}
|
|
80
|
+
};
|
|
81
|
+
/** The scene-wide wetness every Wetness hook follows by default. */
|
|
82
|
+
var sceneWetness = new Wetness();
|
|
83
|
+
var DEFAULTS$1 = {
|
|
84
|
+
color: new Color("#dfe6ee"),
|
|
85
|
+
slope: 140,
|
|
86
|
+
softness: 60,
|
|
87
|
+
strength: {
|
|
88
|
+
bark: 1,
|
|
89
|
+
leaves: .8,
|
|
90
|
+
fruit: .5
|
|
91
|
+
},
|
|
92
|
+
darkening: .4,
|
|
93
|
+
sheen: .6
|
|
94
|
+
};
|
|
95
|
+
/**
|
|
96
|
+
* Makes the ready-made Wetness hooks: trees darken and get a sheen (a lower roughness) by the amount of
|
|
97
|
+
* `wetness` (default {@link sceneWetness}), most on surfaces that face up, drawn to suit the Style:
|
|
98
|
+
* smooth on `'standard'` (realistic), whole facets on `'flat'` (low-poly), and in toon bands with a light
|
|
99
|
+
* glint band on top on `'toon'` (stylized; its lighting has no specular). With the amount at 0 the trees
|
|
100
|
+
* look as without the hooks. They run before the app's own hooks in every stack.
|
|
101
|
+
*/
|
|
102
|
+
function wetnessHooks(settings = {}) {
|
|
103
|
+
const source = settings.wetness ?? sceneWetness;
|
|
104
|
+
const u = {
|
|
105
|
+
color: uniform(DEFAULTS$1.color.clone()),
|
|
106
|
+
dry: uniform(0),
|
|
107
|
+
wet: uniform(0),
|
|
108
|
+
strength: {
|
|
109
|
+
bark: uniform(0),
|
|
110
|
+
leaves: uniform(0),
|
|
111
|
+
fruit: uniform(0)
|
|
112
|
+
},
|
|
113
|
+
darkening: uniform(0),
|
|
114
|
+
sheen: uniform(0)
|
|
115
|
+
};
|
|
116
|
+
const look = {
|
|
117
|
+
...DEFAULTS$1,
|
|
118
|
+
color: DEFAULTS$1.color.clone(),
|
|
119
|
+
strength: { ...DEFAULTS$1.strength }
|
|
120
|
+
};
|
|
121
|
+
const hook = readyMadeShaderHook((input) => {
|
|
122
|
+
const { part, shading, color, roughness, normal } = input;
|
|
123
|
+
const facing = smoothstep(u.dry, u.wet, normal.y);
|
|
124
|
+
const w = (shading === "flat" ? step(.5, facing) : shading === "toon" ? facing.mul(2).add(.5).floor().mul(.5) : facing).mul(source.uniforms.amount).mul(u.strength[part]);
|
|
125
|
+
const tint = u.color;
|
|
126
|
+
const soaked = color.mul(tint).mul(float(1).sub(u.darkening));
|
|
127
|
+
let wetColor = mix(color, soaked, w);
|
|
128
|
+
if (shading === "toon") {
|
|
129
|
+
const glint = smoothstep(.8, .85, normal.y).mul(u.sheen).mul(w).mul(.25);
|
|
130
|
+
wetColor = wetColor.add(tint.mul(glint));
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
color: wetColor,
|
|
134
|
+
roughness: mix(roughness, roughness.mul(float(1).sub(u.sheen)), w)
|
|
135
|
+
};
|
|
136
|
+
});
|
|
137
|
+
return {
|
|
138
|
+
bark: hook,
|
|
139
|
+
leaves: hook,
|
|
140
|
+
fruit: hook,
|
|
141
|
+
wetness: source,
|
|
142
|
+
get settings() {
|
|
143
|
+
return {
|
|
144
|
+
...look,
|
|
145
|
+
color: look.color.clone(),
|
|
146
|
+
strength: { ...look.strength }
|
|
147
|
+
};
|
|
148
|
+
},
|
|
149
|
+
set(next) {
|
|
150
|
+
const slope = next.slope === void 0 ? look.slope : degreesValue("Wetness slope", next.slope, 180);
|
|
151
|
+
const softness = next.softness === void 0 ? look.softness : softnessValue("Wetness softness", next.softness);
|
|
152
|
+
const strength = strengthsWith("Wetness", look.strength, next.strength);
|
|
153
|
+
const darkening = next.darkening === void 0 ? look.darkening : unitValue("Wetness darkening", next.darkening);
|
|
154
|
+
const sheen = next.sheen === void 0 ? look.sheen : unitValue("Wetness sheen", next.sheen);
|
|
155
|
+
if (next.color !== void 0) look.color.set(next.color);
|
|
156
|
+
Object.assign(look, {
|
|
157
|
+
slope,
|
|
158
|
+
softness,
|
|
159
|
+
strength,
|
|
160
|
+
darkening,
|
|
161
|
+
sheen
|
|
162
|
+
});
|
|
163
|
+
u.color.value.copy(look.color);
|
|
164
|
+
const range = slopeRange(look.slope, look.softness);
|
|
165
|
+
u.dry.value = range.none;
|
|
166
|
+
u.wet.value = range.full;
|
|
167
|
+
for (const part of TREE_PARTS) u.strength[part].value = look.strength[part];
|
|
168
|
+
u.darkening.value = look.darkening;
|
|
169
|
+
u.sheen.value = look.sheen;
|
|
170
|
+
return this;
|
|
171
|
+
}
|
|
172
|
+
}.set(settings);
|
|
173
|
+
}
|
|
174
|
+
// src/weather/snow.ts
|
|
175
|
+
/**
|
|
176
|
+
* A snow amount (0..1) that every {@link snowCoverHooks} hook following it whitens trees by, like a `Wind`
|
|
177
|
+
* is shared by the trees swaying with it. Changing it only writes a uniform (no recompile). Snow Cover
|
|
178
|
+
* follows {@link sceneSnow} unless it is given another one.
|
|
179
|
+
*/
|
|
180
|
+
var Snow = class extends WeatherAmount {
|
|
181
|
+
constructor(options = {}) {
|
|
182
|
+
super("Snow amount", options);
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
/** The scene-wide snow amount every Snow Cover follows by default. */
|
|
186
|
+
var sceneSnow = new Snow();
|
|
187
|
+
var DEFAULTS = {
|
|
188
|
+
color: new Color("#f4f8ff"),
|
|
189
|
+
slope: 60,
|
|
190
|
+
softness: 25,
|
|
191
|
+
strength: {
|
|
192
|
+
bark: 1,
|
|
193
|
+
leaves: 1,
|
|
194
|
+
fruit: 1
|
|
195
|
+
}
|
|
196
|
+
};
|
|
197
|
+
/**
|
|
198
|
+
* Makes the ready-made Snow Cover hooks: they whiten the surfaces of trees that face up by the amount of
|
|
199
|
+
* `snow` (default {@link sceneSnow}), drawn to suit the tree's Style: hard flat caps on `'flat'`
|
|
200
|
+
* (low-poly), toon bands on `'toon'` (stylized), soft lit snow with a slight sparkle on `'standard'`
|
|
201
|
+
* (realistic). Snow is read from the world normal after Wind, so it follows swaying branches and lies on
|
|
202
|
+
* bare winter branches when the leaves are gone; undersides stay bare. With the amount at 0 the trees look
|
|
203
|
+
* exactly as without the hooks. They run before the app's own hooks in every stack. A game that wants its
|
|
204
|
+
* own snow can start from {@link snowCoverShading}.
|
|
205
|
+
*/
|
|
206
|
+
function snowCoverHooks(settings = {}) {
|
|
207
|
+
const source = settings.snow ?? sceneSnow;
|
|
208
|
+
const u = {
|
|
209
|
+
color: uniform(DEFAULTS.color.clone()),
|
|
210
|
+
bare: uniform(0),
|
|
211
|
+
covered: uniform(0),
|
|
212
|
+
strength: {
|
|
213
|
+
bark: uniform(0),
|
|
214
|
+
leaves: uniform(0),
|
|
215
|
+
fruit: uniform(0)
|
|
216
|
+
}
|
|
217
|
+
};
|
|
218
|
+
const look = {
|
|
219
|
+
...DEFAULTS,
|
|
220
|
+
color: DEFAULTS.color.clone(),
|
|
221
|
+
strength: { ...DEFAULTS.strength }
|
|
222
|
+
};
|
|
223
|
+
const hook = readyMadeShaderHook((input) => snowCoverShading(input, {
|
|
224
|
+
amount: source.uniforms.amount.mul(u.strength[input.part]),
|
|
225
|
+
color: u.color,
|
|
226
|
+
bare: u.bare,
|
|
227
|
+
covered: u.covered
|
|
228
|
+
}));
|
|
229
|
+
return {
|
|
230
|
+
bark: hook,
|
|
231
|
+
leaves: hook,
|
|
232
|
+
fruit: hook,
|
|
233
|
+
snow: source,
|
|
234
|
+
get settings() {
|
|
235
|
+
return {
|
|
236
|
+
...look,
|
|
237
|
+
color: look.color.clone(),
|
|
238
|
+
strength: { ...look.strength }
|
|
239
|
+
};
|
|
240
|
+
},
|
|
241
|
+
set(next) {
|
|
242
|
+
const slope = next.slope === void 0 ? look.slope : degreesValue("Snow Cover slope", next.slope, 90);
|
|
243
|
+
const softness = next.softness === void 0 ? look.softness : softnessValue("Snow Cover softness", next.softness);
|
|
244
|
+
const strength = strengthsWith("Snow Cover", look.strength, next.strength);
|
|
245
|
+
if (next.color !== void 0) look.color.set(next.color);
|
|
246
|
+
Object.assign(look, {
|
|
247
|
+
slope,
|
|
248
|
+
softness,
|
|
249
|
+
strength
|
|
250
|
+
});
|
|
251
|
+
u.color.value.copy(look.color);
|
|
252
|
+
const range = slopeRange(look.slope, look.softness);
|
|
253
|
+
u.bare.value = range.none;
|
|
254
|
+
u.covered.value = range.full;
|
|
255
|
+
for (const part of TREE_PARTS) u.strength[part].value = look.strength[part];
|
|
256
|
+
return this;
|
|
257
|
+
}
|
|
258
|
+
}.set(settings);
|
|
259
|
+
}
|
|
260
|
+
var SNOW_ROUGHNESS = .75;
|
|
261
|
+
/**
|
|
262
|
+
* The shading of Snow Cover, as a plain Tree Shader Hook body: a starting point for a game's own snow
|
|
263
|
+
* (`const mySnow: TreeShaderHook = (input) => snowCoverShading(input, { ... })`). It only uses the hook's
|
|
264
|
+
* inputs and the settings given.
|
|
265
|
+
*/
|
|
266
|
+
function snowCoverShading(input, settings) {
|
|
267
|
+
const { shading, color, roughness, position } = input;
|
|
268
|
+
const { amount, bare, covered } = settings;
|
|
269
|
+
const lies = smoothstep(bare, covered, input.normal.normalize().y);
|
|
270
|
+
let cover;
|
|
271
|
+
let snow = settings.color;
|
|
272
|
+
if (shading === "flat") cover = step(.5, lies).mul(amount);
|
|
273
|
+
else if (shading === "toon") cover = lies.mul(amount).mul(3).add(.5).floor().div(3);
|
|
274
|
+
else {
|
|
275
|
+
cover = lies.mul(amount);
|
|
276
|
+
const view = cameraPosition.sub(position).normalize();
|
|
277
|
+
const cell = position.mul(60).floor().add(view.mul(6).floor());
|
|
278
|
+
const glint = step(.985, hash(cell.x.add(cell.y.mul(57)).add(cell.z.mul(113))));
|
|
279
|
+
snow = snow.mul(glint.mul(.35).add(1));
|
|
280
|
+
}
|
|
281
|
+
return {
|
|
282
|
+
color: color.add(snow.sub(color).mul(cover)),
|
|
283
|
+
roughness: roughness.add(float(SNOW_ROUGHNESS).sub(roughness).mul(cover))
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
export { Snow, Wetness, sceneSnow, sceneWetness, snowCoverHooks, snowCoverShading, wetnessHooks };
|
|
287
|
+
|
|
288
|
+
//# sourceMappingURL=weather.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"weather.js","names":["DEFAULTS"],"sources":["../src/weather/shared.ts","../src/weather/wetness.ts","../src/weather/snow.ts"],"sourcesContent":["import { uniform } from 'three/tsl';\nimport type { UniformNode } from 'three/webgpu';\nimport { TREE_PARTS, type TreePart } from '../effects/mask';\n\n/** The options of a scene-wide weather amount ({@link WeatherAmount}). */\nexport interface WeatherAmountOptions {\n /** 0 (none, default) .. 1 (full). */\n amount?: number;\n}\n\n/**\n * A scene-wide weather amount (0..1) that ready-made hooks follow, shared like a `Wind`: changing it only\n * writes a uniform (no recompile). The base of `Snow` and `Wetness`.\n */\nexport abstract class WeatherAmount {\n /** The shared TSL uniforms the hooks read. Write through the setters, not here. */\n readonly uniforms: { readonly amount: UniformNode<'float', number> };\n\n /** `label`: how errors name the amount, e.g. 'Snow amount'. */\n protected constructor(\n private readonly label: string,\n options: WeatherAmountOptions,\n ) {\n this.uniforms = { amount: uniform(0) };\n this.set(options);\n }\n\n get amount(): number {\n return this.uniforms.amount.value;\n }\n\n set amount(value: number) {\n this.uniforms.amount.value = unitValue(this.label, value);\n }\n\n /** Sets the amount; returns this. */\n set(options: WeatherAmountOptions): this {\n if (options.amount !== undefined) this.amount = options.amount;\n return this;\n }\n}\n\n/** `value` if it is in 0..1; throws a RangeError naming `label` otherwise. */\nexport function unitValue(label: string, value: number): number {\n if (!(value >= 0 && value <= 1)) throw new RangeError(`${label} must be a number in 0..1, got ${value}`);\n return value;\n}\n\n/** `value` if it is an angle in 0..`max` degrees; throws a RangeError naming `label` otherwise. */\nexport function degreesValue(label: string, value: number, max: number): number {\n if (!(value >= 0 && value <= max)) throw new RangeError(`${label} must be 0..${max} degrees, got ${value}`);\n return value;\n}\n\n/** `value` if it is a finite number >= 0; throws a RangeError naming `label` otherwise. */\nexport function softnessValue(label: string, value: number): number {\n if (!(value >= 0 && Number.isFinite(value))) throw new RangeError(`${label} must be a finite number >= 0, got ${value}`);\n return value;\n}\n\n/** `current` with the per-part strengths of `next` (each checked to be 0..1, `label` names them in errors). */\nexport function strengthsWith(label: string, current: Record<TreePart, number>, next: Partial<Record<TreePart, number>> | undefined): Record<TreePart, number> {\n const strength = { ...current };\n for (const part of TREE_PARTS) {\n const value = next?.[part];\n if (value !== undefined) strength[part] = unitValue(`${label} ${part} strength`, value);\n }\n return strength;\n}\n\n/**\n * The world normal's y range of a slope setting, shared by Snow Cover and Wetness: `slope` is how far a\n * surface may tilt from level (its normal from straight up, in degrees) and still take any; `softness`\n * the degrees below `slope` over which it fades in. `none`: the normal's y at `slope` (none at or beyond\n * it); `full`: at `slope - softness` (full from there up), always above `none`.\n */\nexport function slopeRange(slope: number, softness: number): { none: number; full: number } {\n const cosOf = (degrees: number) => Math.cos((Math.min(180, Math.max(0, degrees)) * Math.PI) / 180);\n const none = cosOf(slope);\n return { none, full: Math.max(cosOf(slope - softness), none + 1e-4) };\n}\n","import { float, mix, smoothstep, step, uniform } from 'three/tsl';\nimport { Color, type ColorRepresentation, type Node } from 'three/webgpu';\nimport { TREE_PARTS, type TreePart } from '../effects/mask';\nimport { readyMadeShaderHook, type TreeShaderHook, type TreeShaderInput } from '../materials/shader-hooks';\nimport { degreesValue, slopeRange, softnessValue, strengthsWith, unitValue, WeatherAmount } from './shared';\n\nexport interface WetnessOptions {\n /** How wet the trees are: 0 = dry (default), 1 = soaked. */\n amount?: number;\n}\n\n/**\n * A scene-wide wetness amount (0..1) that every {@link wetnessHooks} hook reading it follows, as after\n * rain. Shared like `sceneWind`: hooks use {@link sceneWetness} unless given another one. Changing it only\n * writes a uniform (no recompile).\n */\nexport class Wetness extends WeatherAmount {\n constructor(options: WetnessOptions = {}) {\n super('Wetness amount', options);\n }\n}\n\n/** The scene-wide wetness every Wetness hook follows by default. */\nexport const sceneWetness = new Wetness();\n\n/** How a {@link wetnessHooks} hook looks; every setting is live (a uniform write, no rebuild). */\nexport interface WetnessSettings {\n /** The tint wet surfaces take on (multiplied into their colour). Default a cool grey, `#dfe6ee`. */\n color?: ColorRepresentation;\n /**\n * The steepest surface that still gets wet, in degrees from level (the same as how far its normal is\n * from facing straight up), as Snow Cover's `slope`, but up to 180 (facing straight down): sides and\n * undersides get wet too. Default 140 (only surfaces facing well down stay dry).\n */\n slope?: number;\n /**\n * Degrees (>= 0) below `slope` over which wetness fades out towards it: fully wet up to\n * `slope - softness`, dry from `slope` on, as Snow Cover's `softness`. Default 60; 0 is a hard edge.\n */\n softness?: number;\n /** How much each tree part takes (0..1). Default bark 1, leaves 0.8, fruit 0.5. */\n strength?: Partial<Record<TreePart, number>>;\n /** How much darker a soaked surface gets (0..1). Default 0.4. */\n darkening?: number;\n /** How much a soaked surface's roughness drops, so it shines (0..1). Default 0.6. */\n sheen?: number;\n}\n\n/** The settings of a {@link wetnessHooks} hook, all given. */\nexport interface WetnessLook {\n color: Color;\n slope: number;\n softness: number;\n strength: Record<TreePart, number>;\n darkening: number;\n sheen: number;\n}\n\n/**\n * The ready-made Wetness hooks (GLOSSARY: Wetness) for bark, leaves and fruit: a set of Tree Shader Hooks\n * to hand to a Tree, a Forest, `setSceneShaderHooks` or `stackShaderHooks`, with live settings.\n */\nexport interface WetnessHooks {\n readonly bark: TreeShaderHook;\n readonly leaves: TreeShaderHook;\n readonly fruit: TreeShaderHook;\n /** The amount the hooks follow. */\n readonly wetness: Wetness;\n /** The current settings (a copy). */\n readonly settings: WetnessLook;\n /** Changes settings live (uniform writes, no rebuild); returns this. */\n set(settings: WetnessSettings): this;\n}\n\nconst DEFAULTS: WetnessLook = {\n color: new Color('#dfe6ee'),\n slope: 140,\n softness: 60,\n strength: { bark: 1, leaves: 0.8, fruit: 0.5 },\n darkening: 0.4,\n sheen: 0.6,\n};\n\n/**\n * Makes the ready-made Wetness hooks: trees darken and get a sheen (a lower roughness) by the amount of\n * `wetness` (default {@link sceneWetness}), most on surfaces that face up, drawn to suit the Style:\n * smooth on `'standard'` (realistic), whole facets on `'flat'` (low-poly), and in toon bands with a light\n * glint band on top on `'toon'` (stylized; its lighting has no specular). With the amount at 0 the trees\n * look as without the hooks. They run before the app's own hooks in every stack.\n */\nexport function wetnessHooks(settings: WetnessSettings & { wetness?: Wetness } = {}): WetnessHooks {\n const source = settings.wetness ?? sceneWetness;\n const u = {\n color: uniform(DEFAULTS.color.clone()),\n // The normal's y at which wetness has faded out (dry, `slope`) and from which on it is full.\n dry: uniform(0),\n wet: uniform(0),\n strength: { bark: uniform(0), leaves: uniform(0), fruit: uniform(0) },\n darkening: uniform(0),\n sheen: uniform(0),\n };\n const look: WetnessLook = { ...DEFAULTS, color: DEFAULTS.color.clone(), strength: { ...DEFAULTS.strength } };\n\n // One hook for every part (it reads the part from its input), marked ready-made so it runs first.\n const hook = readyMadeShaderHook((input: TreeShaderInput) => {\n const { part, shading, color, roughness, normal } = input;\n const facing = smoothstep(u.dry, u.wet, normal.y);\n // Flat: each facet is wet or not; toon: bands of none, half and full; standard: smooth.\n const coverage: Node<'float'> =\n shading === 'flat' ? step(0.5, facing) : shading === 'toon' ? facing.mul(2).add(0.5).floor().mul(0.5) : facing;\n const w = coverage.mul(source.uniforms.amount).mul(u.strength[part]);\n const tint = u.color as unknown as Node<'vec3'>;\n const soaked = color.mul(tint).mul(float(1).sub(u.darkening));\n let wetColor: Node<'vec3'> = mix(color, soaked, w);\n if (shading === 'toon') {\n // A light glint band on the surfaces that face most up: toon lighting draws no specular.\n const glint = smoothstep(0.8, 0.85, normal.y).mul(u.sheen).mul(w).mul(0.25);\n wetColor = wetColor.add(tint.mul(glint));\n }\n return { color: wetColor, roughness: mix(roughness, roughness.mul(float(1).sub(u.sheen)), w) };\n });\n\n const hooks: WetnessHooks = {\n bark: hook,\n leaves: hook,\n fruit: hook,\n wetness: source,\n get settings() {\n return { ...look, color: look.color.clone(), strength: { ...look.strength } };\n },\n set(next: WetnessSettings) {\n // Checked in full before anything is written, so a bad value changes nothing.\n const slope = next.slope === undefined ? look.slope : degreesValue('Wetness slope', next.slope, 180);\n const softness = next.softness === undefined ? look.softness : softnessValue('Wetness softness', next.softness);\n const strength = strengthsWith('Wetness', look.strength, next.strength);\n const darkening = next.darkening === undefined ? look.darkening : unitValue('Wetness darkening', next.darkening);\n const sheen = next.sheen === undefined ? look.sheen : unitValue('Wetness sheen', next.sheen);\n if (next.color !== undefined) look.color.set(next.color);\n Object.assign(look, { slope, softness, strength, darkening, sheen });\n u.color.value.copy(look.color);\n const range = slopeRange(look.slope, look.softness);\n u.dry.value = range.none;\n u.wet.value = range.full;\n for (const part of TREE_PARTS) u.strength[part].value = look.strength[part];\n u.darkening.value = look.darkening;\n u.sheen.value = look.sheen;\n return this;\n },\n };\n return hooks.set(settings);\n}\n","import { Color, type ColorRepresentation, type Node } from 'three/webgpu';\nimport { cameraPosition, float, hash, smoothstep, step, uniform } from 'three/tsl';\nimport { TREE_PARTS, type TreePart } from '../effects/mask';\nimport { readyMadeShaderHook, type TreeShaderHook, type TreeShaderInput, type TreeShaderOutput } from '../materials/shader-hooks';\nimport { degreesValue, slopeRange, softnessValue, strengthsWith, WeatherAmount } from './shared';\n\nexport interface SnowOptions {\n /** How much snow lies on the trees: 0 = none (default), 1 = full cover. */\n amount?: number;\n}\n\n/**\n * A snow amount (0..1) that every {@link snowCoverHooks} hook following it whitens trees by, like a `Wind`\n * is shared by the trees swaying with it. Changing it only writes a uniform (no recompile). Snow Cover\n * follows {@link sceneSnow} unless it is given another one.\n */\nexport class Snow extends WeatherAmount {\n constructor(options: SnowOptions = {}) {\n super('Snow amount', options);\n }\n}\n\n/** The scene-wide snow amount every Snow Cover follows by default. */\nexport const sceneSnow = new Snow();\n\n/** How Snow Cover ({@link snowCoverHooks}) looks; every setting is live (a uniform write, no rebuild). */\nexport interface SnowCoverSettings {\n /** Snow colour (sRGB, like any three.js colour). Default `#f4f8ff`, a slightly blue white. */\n color?: ColorRepresentation;\n /**\n * The steepest surface that still holds snow, in degrees from level (0..90; the same as how far its\n * normal is from facing straight up), as Wetness's `slope`. Default 60.\n */\n slope?: number;\n /**\n * Degrees (>= 0) below `slope` over which the snow fades out towards it: full up to `slope - softness`,\n * none from `slope` on, as Wetness's `softness`. Default 25; 0 is a hard edge.\n */\n softness?: number;\n /** How much snow each tree part takes (0..1). Default 1 for bark, leaves and fruit. */\n strength?: Partial<Record<TreePart, number>>;\n}\n\n/** The settings of a {@link snowCoverHooks} hook, all given. */\nexport interface SnowCoverLook {\n color: Color;\n slope: number;\n softness: number;\n strength: Record<TreePart, number>;\n}\n\n/**\n * The ready-made Snow Cover hooks (GLOSSARY: Snow Cover) for bark, leaves and fruit: a set of Tree Shader\n * Hooks to hand to a Tree, a Forest, `setSceneShaderHooks` or `stackShaderHooks`, with live settings.\n */\nexport interface SnowCoverHooks {\n readonly bark: TreeShaderHook;\n readonly leaves: TreeShaderHook;\n readonly fruit: TreeShaderHook;\n /** The snow amount the hooks follow. */\n readonly snow: Snow;\n /** The current settings (a copy). */\n readonly settings: SnowCoverLook;\n /** Changes settings live (uniform writes, no rebuild); returns this. */\n set(settings: SnowCoverSettings): this;\n}\n\nconst DEFAULTS: SnowCoverLook = {\n color: new Color('#f4f8ff'),\n slope: 60,\n softness: 25,\n strength: { bark: 1, leaves: 1, fruit: 1 },\n};\n\n/**\n * Makes the ready-made Snow Cover hooks: they whiten the surfaces of trees that face up by the amount of\n * `snow` (default {@link sceneSnow}), drawn to suit the tree's Style: hard flat caps on `'flat'`\n * (low-poly), toon bands on `'toon'` (stylized), soft lit snow with a slight sparkle on `'standard'`\n * (realistic). Snow is read from the world normal after Wind, so it follows swaying branches and lies on\n * bare winter branches when the leaves are gone; undersides stay bare. With the amount at 0 the trees look\n * exactly as without the hooks. They run before the app's own hooks in every stack. A game that wants its\n * own snow can start from {@link snowCoverShading}.\n */\nexport function snowCoverHooks(settings: SnowCoverSettings & { snow?: Snow } = {}): SnowCoverHooks {\n const source = settings.snow ?? sceneSnow;\n const u = {\n color: uniform(DEFAULTS.color.clone()),\n // The normal's y at which a surface is bare (`slope`) and from which on it is fully covered.\n bare: uniform(0),\n covered: uniform(0),\n strength: { bark: uniform(0), leaves: uniform(0), fruit: uniform(0) },\n };\n const look: SnowCoverLook = { ...DEFAULTS, color: DEFAULTS.color.clone(), strength: { ...DEFAULTS.strength } };\n\n // One hook for every part (it reads the part from its input), marked ready-made so it runs first.\n const hook = readyMadeShaderHook((input: TreeShaderInput) =>\n snowCoverShading(input, {\n amount: source.uniforms.amount.mul(u.strength[input.part]),\n color: u.color as unknown as Node<'vec3'>,\n bare: u.bare,\n covered: u.covered,\n }),\n );\n\n const hooks: SnowCoverHooks = {\n bark: hook,\n leaves: hook,\n fruit: hook,\n snow: source,\n get settings() {\n return { ...look, color: look.color.clone(), strength: { ...look.strength } };\n },\n set(next: SnowCoverSettings) {\n // Checked in full before anything is written, so a bad value changes nothing.\n const slope = next.slope === undefined ? look.slope : degreesValue('Snow Cover slope', next.slope, 90);\n const softness = next.softness === undefined ? look.softness : softnessValue('Snow Cover softness', next.softness);\n const strength = strengthsWith('Snow Cover', look.strength, next.strength);\n if (next.color !== undefined) look.color.set(next.color);\n Object.assign(look, { slope, softness, strength });\n u.color.value.copy(look.color);\n const range = slopeRange(look.slope, look.softness);\n u.bare.value = range.none;\n u.covered.value = range.full;\n for (const part of TREE_PARTS) u.strength[part].value = look.strength[part];\n return this;\n },\n };\n return hooks.set(settings);\n}\n\n/** The settings {@link snowCoverShading} draws with, as TSL nodes (uniforms, so they can change live). */\nexport interface SnowCoverShadingSettings {\n /** How much snow (0..1): the snow amount times the part's strength. */\n amount: Node<'float'>;\n /** Snow colour (linear rgb). */\n color: Node<'vec3'>;\n /** The world normal's y at or below which a surface stays bare (the cosine of the steepest slope that holds snow). */\n bare: Node<'float'>;\n /** The world normal's y from which on a surface is fully covered (> `bare`). */\n covered: Node<'float'>;\n}\n\nconst SNOW_ROUGHNESS = 0.75;\n\n/**\n * The shading of Snow Cover, as a plain Tree Shader Hook body: a starting point for a game's own snow\n * (`const mySnow: TreeShaderHook = (input) => snowCoverShading(input, { ... })`). It only uses the hook's\n * inputs and the settings given.\n */\nexport function snowCoverShading(input: TreeShaderInput, settings: SnowCoverShadingSettings): TreeShaderOutput {\n const { shading, color, roughness, position } = input;\n const { amount, bare, covered } = settings;\n\n // How much a surface faces up, from bare (as steep as `slope`, or steeper, or facing down) to covered.\n // The normal is the one lit, after Wind: snow sways with the branch it lies on.\n const lies = smoothstep(bare, covered, input.normal.normalize().y);\n\n let cover: Node<'float'>;\n let snow: Node<'vec3'> = settings.color;\n if (shading === 'flat') {\n // Low-poly: flat caps. A facet holds snow or not (its normal is the facet's), no soft edge on it.\n cover = step(0.5, lies).mul(amount);\n } else if (shading === 'toon') {\n // Stylized: toon bands. The cover in three steps, so the edge reads as bands, like the toon light.\n cover = lies.mul(amount).mul(3).add(0.5).floor().div(3);\n } else {\n // Realistic: soft, lit snow with a slight sparkle: a few tiny cells glint, changing with the view.\n cover = lies.mul(amount);\n const view = cameraPosition.sub(position).normalize();\n const cell = position.mul(60).floor().add(view.mul(6).floor());\n const glint = step(0.985, hash(cell.x.add(cell.y.mul(57)).add(cell.z.mul(113))));\n snow = snow.mul(glint.mul(0.35).add(1));\n }\n\n // Exactly the colour and roughness given where `cover` is 0.\n return {\n color: color.add(snow.sub(color).mul(cover)),\n roughness: roughness.add(float(SNOW_ROUGHNESS).sub(roughness).mul(cover)),\n };\n}\n"],"mappings":";;;;;;;;;AAcA,IAAsB,gBAAtB,MAAoC;CAMf;;CAJnB;;CAGA,YACE,OACA,SACA;EAFiB,KAAA,QAAA;EAGjB,KAAK,WAAW,EAAE,QAAQ,QAAQ,CAAC,EAAE;EACrC,KAAK,IAAI,OAAO;CAClB;CAEA,IAAI,SAAiB;EACnB,OAAO,KAAK,SAAS,OAAO;CAC9B;CAEA,IAAI,OAAO,OAAe;EACxB,KAAK,SAAS,OAAO,QAAQ,UAAU,KAAK,OAAO,KAAK;CAC1D;;CAGA,IAAI,SAAqC;EACvC,IAAI,QAAQ,WAAW,KAAA,GAAW,KAAK,SAAS,QAAQ;EACxD,OAAO;CACT;AACF;;AAGA,SAAgB,UAAU,OAAe,OAAuB;CAC9D,IAAI,EAAE,SAAS,KAAK,SAAS,IAAI,MAAM,IAAI,WAAW,G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