@casmo/tree.js 0.4.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 +590 -4
- package/dist/effects/custom.d.ts +62 -0
- package/dist/effects/custom.d.ts.map +1 -0
- package/dist/effects/effects.d.ts +42 -1
- package/dist/effects/effects.d.ts.map +1 -1
- package/dist/effects/index.d.ts +2 -0
- package/dist/effects/index.d.ts.map +1 -1
- package/dist/effects/mask.d.ts +9 -1
- package/dist/effects/mask.d.ts.map +1 -1
- package/dist/effects/tree-id.d.ts.map +1 -1
- package/dist/effects-qHx_8Dlk.js +1052 -0
- package/dist/effects-qHx_8Dlk.js.map +1 -0
- package/dist/effects.js +2 -963
- package/dist/forest/Forest.d.ts +80 -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-lg61rhKM.js → forest-CM5DrklM.js} +1723 -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-lg61rhKM.js.map +0 -1
package/dist/wind/Wind.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Vector3, type UniformNode } from 'three/webgpu';
|
|
1
|
+
import { Vector3, type UniformArrayNode, type UniformNode } from 'three/webgpu';
|
|
2
2
|
export type WindDirection = Vector3 | readonly [number, number, number];
|
|
3
3
|
export interface WindOptions {
|
|
4
4
|
/** World-space direction the wind blows towards (any length > 0; stored as a unit vector). Default +X. */
|
|
@@ -6,6 +6,53 @@ export interface WindOptions {
|
|
|
6
6
|
/** 0 = calm (default), 1 = strong wind; larger values are allowed for storms. */
|
|
7
7
|
strength?: number;
|
|
8
8
|
}
|
|
9
|
+
/** A {@link Wind.burst}: where on the ground, how hard and how far. */
|
|
10
|
+
export interface WindBurstOptions {
|
|
11
|
+
/** World-space ground point (x, z) the air pushes away from. */
|
|
12
|
+
x: number;
|
|
13
|
+
z: number;
|
|
14
|
+
/**
|
|
15
|
+
* How hard it pushes (default 1). Weaker values push less; a negative value is the reduced-motion
|
|
16
|
+
* burst: trees in reach lean away at once (no travelling front, no swing back) and settle, with
|
|
17
|
+
* the size of the value as strength.
|
|
18
|
+
*/
|
|
19
|
+
strength?: number;
|
|
20
|
+
/** Metres it reaches (> 0). Default {@link WIND_BURST_REACH} per unit of strength. */
|
|
21
|
+
radius?: number;
|
|
22
|
+
}
|
|
23
|
+
/** A running Wind Burst, as {@link Wind.bursts} lists it. */
|
|
24
|
+
export interface WindBurst {
|
|
25
|
+
readonly x: number;
|
|
26
|
+
readonly z: number;
|
|
27
|
+
readonly strength: number;
|
|
28
|
+
readonly radius: number;
|
|
29
|
+
/** The Wind time (seconds) it started at. */
|
|
30
|
+
readonly start: number;
|
|
31
|
+
}
|
|
32
|
+
/** Seconds a Wind Burst lasts. */
|
|
33
|
+
export declare const WIND_BURST_LIFETIME = 1.2;
|
|
34
|
+
/** Most Wind Bursts one Wind runs at once; a new one beyond it replaces the oldest. */
|
|
35
|
+
export declare const MAX_WIND_BURSTS = 8;
|
|
36
|
+
/** Metres a Wind Burst reaches per unit of strength, unless given a `radius`. */
|
|
37
|
+
export declare const WIND_BURST_REACH = 8;
|
|
38
|
+
/** Something that switches Wind Bursts on once they are used (see {@link WindBurstsUsed}). */
|
|
39
|
+
export interface BurstListener {
|
|
40
|
+
burstsUsed(): void;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Whether a Wind (or a {@link WindBinding}) has ever had a Wind Burst. Tree materials only get burst
|
|
44
|
+
* nodes once it has: until then they are exactly as without Wind Bursts. Listeners are held weakly and
|
|
45
|
+
* told once.
|
|
46
|
+
*/
|
|
47
|
+
export declare class WindBurstsUsed {
|
|
48
|
+
private used;
|
|
49
|
+
private listeners;
|
|
50
|
+
get triggered(): boolean;
|
|
51
|
+
/** Tells `listener` (at once if already triggered) when the first burst comes. */
|
|
52
|
+
listen(listener: BurstListener): void;
|
|
53
|
+
/** Marks bursts as used and tells every listener (only the first time). */
|
|
54
|
+
trigger(): void;
|
|
55
|
+
}
|
|
9
56
|
/**
|
|
10
57
|
* Scene-wide Wind: a direction and a strength that every tree listening to it sways with.
|
|
11
58
|
* Changing them only writes uniform values (no recompile). Trees use {@link sceneWind} unless
|
|
@@ -19,8 +66,14 @@ export declare class Wind {
|
|
|
19
66
|
readonly strength: UniformNode<'float', number>;
|
|
20
67
|
/** Seconds; follows the renderer clock unless {@link Wind.time} pins it. */
|
|
21
68
|
readonly time: UniformNode<'float', number>;
|
|
69
|
+
/** Wind Bursts (see {@link WindBurstUniforms}). */
|
|
70
|
+
readonly bursts: WindBurstUniforms;
|
|
22
71
|
};
|
|
23
72
|
private pinnedTime;
|
|
73
|
+
/** The renderer clock as last seen by a render (the Wind time when not pinned). */
|
|
74
|
+
private clock;
|
|
75
|
+
/** Running and recently ended bursts, oldest first (at most {@link MAX_WIND_BURSTS}). */
|
|
76
|
+
private started;
|
|
24
77
|
constructor(options?: WindOptions);
|
|
25
78
|
/** Unit direction the wind blows towards (a copy: assign a new value to change it). */
|
|
26
79
|
get direction(): Vector3;
|
|
@@ -33,6 +86,29 @@ export declare class Wind {
|
|
|
33
86
|
*/
|
|
34
87
|
get time(): number | null;
|
|
35
88
|
set time(value: number | null);
|
|
89
|
+
/**
|
|
90
|
+
* Starts a Wind Burst: a short push of air from a ground point that bends the trees within its
|
|
91
|
+
* radius away from it and fades out within {@link WIND_BURST_LIFETIME} seconds of Wind time, on top
|
|
92
|
+
* of the Wind. At most {@link MAX_WIND_BURSTS} run at once; another one replaces the oldest. Only
|
|
93
|
+
* uniform writes, except that the first burst on a Wind rebuilds the node graphs of the trees swaying
|
|
94
|
+
* with it once (never their geometry): until then their materials have no burst nodes at all. Returns this.
|
|
95
|
+
*/
|
|
96
|
+
burst({ x, z, strength, radius }: WindBurstOptions): this;
|
|
97
|
+
/**
|
|
98
|
+
* @internal The bursts the shader loops over (oldest first, at most {@link MAX_WIND_BURSTS}): the
|
|
99
|
+
* started ones while any of them runs, else none. They only change in {@link Wind.burst}; the
|
|
100
|
+
* shader leaves out those that have not started or have ended.
|
|
101
|
+
*/
|
|
102
|
+
get drawnBursts(): readonly WindBurst[];
|
|
103
|
+
/** The Wind Bursts running at the current Wind time, oldest first. */
|
|
104
|
+
get bursts(): WindBurst[];
|
|
105
|
+
/**
|
|
106
|
+
* @internal The Wind time of a render at renderer time `frameTime` (called once per render by
|
|
107
|
+
* the Wind's own and its bindings' time uniforms): the pinned time, or that clock, which it keeps.
|
|
108
|
+
*/
|
|
109
|
+
timeAt(frameTime: number): number;
|
|
110
|
+
/** The current Wind time: the pinned time, or the renderer clock as of the last render. */
|
|
111
|
+
private get now();
|
|
36
112
|
/** Sets direction and/or strength; returns this. */
|
|
37
113
|
set(options: WindOptions): this;
|
|
38
114
|
}
|
|
@@ -43,12 +119,31 @@ export type WindUniforms = Wind['uniforms'];
|
|
|
43
119
|
/**
|
|
44
120
|
* Per-object Wind uniforms that follow whichever Wind is bound to them, read once per render.
|
|
45
121
|
* Trees and Forests build their Wind nodes on these, so switching to another Wind is one
|
|
46
|
-
* assignment: no new nodes, no recompile, no regeneration
|
|
122
|
+
* assignment: no new nodes, no recompile, no regeneration (only the first time the binding follows a
|
|
123
|
+
* Wind that has had a Wind Burst do the materials built on it add burst nodes, one rebuild).
|
|
47
124
|
*/
|
|
48
|
-
export declare class WindBinding {
|
|
49
|
-
/** The bound Wind. */
|
|
50
|
-
wind: Wind;
|
|
125
|
+
export declare class WindBinding implements BurstListener {
|
|
51
126
|
readonly uniforms: WindUniforms;
|
|
127
|
+
private bound;
|
|
52
128
|
constructor(wind: Wind);
|
|
129
|
+
/** The bound Wind. Binding one that has had a Wind Burst switches bursts on (see {@link WindBurstsUsed}). */
|
|
130
|
+
get wind(): Wind;
|
|
131
|
+
set wind(value: Wind);
|
|
132
|
+
/** @internal A Wind this binding listened to had its first burst: switch bursts on if it is still the bound one. */
|
|
133
|
+
burstsUsed(): void;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* The Wind Burst uniforms tree materials read: a fixed-size array of {@link MAX_WIND_BURSTS} slots,
|
|
137
|
+
* and how many of them to loop over (0 when no burst runs, so the loop costs nothing). Tree materials
|
|
138
|
+
* only read them once a burst has been triggered (`used`).
|
|
139
|
+
*/
|
|
140
|
+
export interface WindBurstUniforms {
|
|
141
|
+
/** Per slot: x, z (world-space ground point), start (Wind time), strength. */
|
|
142
|
+
readonly points: UniformArrayNode<'vec4'>;
|
|
143
|
+
/** Per slot: the radius in metres. */
|
|
144
|
+
readonly radii: UniformArrayNode<'float'>;
|
|
145
|
+
readonly count: UniformNode<'int', number>;
|
|
146
|
+
/** Whether any burst has been triggered (then materials add burst nodes; see {@link WindBurstsUsed}). */
|
|
147
|
+
readonly used: WindBurstsUsed;
|
|
53
148
|
}
|
|
54
149
|
//# sourceMappingURL=Wind.d.ts.map
|
package/dist/wind/Wind.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Wind.d.ts","sourceRoot":"","sources":["../../src/wind/Wind.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"Wind.d.ts","sourceRoot":"","sources":["../../src/wind/Wind.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAW,KAAK,gBAAgB,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAGzF,MAAM,MAAM,aAAa,GAAG,OAAO,GAAG,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAExE,MAAM,WAAW,WAAW;IAC1B,0GAA0G;IAC1G,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,iFAAiF;IACjF,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,uEAAuE;AACvE,MAAM,WAAW,gBAAgB;IAC/B,gEAAgE;IAChE,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV;;;;OAIG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,sFAAsF;IACtF,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,6DAA6D;AAC7D,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,6CAA6C;IAC7C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,kCAAkC;AAClC,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C;CAC/B"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Node } from 'three/webgpu';
|
|
2
|
+
import type { WindSource } from './node';
|
|
3
|
+
/**
|
|
4
|
+
* TSL node: the push of the Wind Bursts of `wind` at a world-space ground point `xz` (vec2: world
|
|
5
|
+
* x, z), summed over the running bursts: away from each burst point, about 0..0.75 × strength at
|
|
6
|
+
* its peak, 0 beyond the burst's radius and once it has ended. `time` is the Wind time to evaluate
|
|
7
|
+
* it at (default the Wind's clock), e.g. the previous frame's for Wind-aware velocity. With no
|
|
8
|
+
* burst running the loop runs zero times and the push is exactly 0.
|
|
9
|
+
*/
|
|
10
|
+
export declare function windBurstPush(wind: WindSource, xz: Node<'vec2'>, time?: Node<'float'>): Node<'vec2'>;
|
|
11
|
+
/**
|
|
12
|
+
* Where a Wind Burst finds a tree and how its push turns into the tree's space: a Tree is the
|
|
13
|
+
* rendered object ({@link objectBurstFrame}); a tree drawn as an instance passes its own.
|
|
14
|
+
*/
|
|
15
|
+
export interface WindBurstFrame {
|
|
16
|
+
/** The tree's world-space ground point (vec2: world x, z). */
|
|
17
|
+
origin: Node<'vec2'>;
|
|
18
|
+
/** Turns a world-space vector into the tree's space: rotation only, its length kept. */
|
|
19
|
+
toTree(world: Node<'vec3'>): Node<'vec3'>;
|
|
20
|
+
}
|
|
21
|
+
/** The {@link WindBurstFrame} of a tree that is one object: its world origin and rotation. */
|
|
22
|
+
export declare function objectBurstFrame(): WindBurstFrame;
|
|
23
|
+
/**
|
|
24
|
+
* TSL node: the Wind displacement `still`, plus Wind Bursts once `source`'s Wind has had one: then
|
|
25
|
+
* `withBursts()` (built at that moment, once). See {@link WindBurstSwitchNode}.
|
|
26
|
+
*/
|
|
27
|
+
export declare function withWindBursts(source: WindSource, still: Node<'vec3'>, withBursts: () => Node<'vec3'>): Node<'vec3'>;
|
|
28
|
+
//# sourceMappingURL=burst.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"burst.d.ts","sourceRoot":"","sources":["../../src/wind/burst.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAA0D,MAAM,cAAc,CAAC;AAG5F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAgBzC;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,UAAU,EAAE,EAAE,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,GAAE,IAAI,CAAC,OAAO,CAAsB,GAAG,IAAI,CAAC,MAAM,CAAC,CAIxH;AAwBD;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,8DAA8D;IAC9D,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACrB,wFAAwF;IACxF,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;CAC3C;AAED,8FAA8F;AAC9F,wBAAgB,gBAAgB,IAAI,cAAc,CASjD;AAgDD;;;GAGG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAEpH"}
|
package/dist/wind/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export { Wind, WindBinding, sceneWind, type WindDirection, type WindOptions, type WindUniforms } from './Wind';
|
|
1
|
+
export { Wind, WindBinding, sceneWind, MAX_WIND_BURSTS, WIND_BURST_LIFETIME, WIND_BURST_REACH, type WindBurst, type WindBurstOptions, type WindBurstUniforms, type WindDirection, type WindOptions, type WindUniforms, } from './Wind';
|
|
2
|
+
export { windBurstPush, objectBurstFrame, type WindBurstFrame } from './burst';
|
|
2
3
|
export { WindResponse } from './response';
|
|
3
|
-
export { windOffset, applyWind, objectWindDirection, type WindFrame, type WindSource } from './node';
|
|
4
|
+
export { windOffset, treeSwayOffset, applyWind, objectWindDirection, type WindFrame, type WindSource } from './node';
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/wind/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/wind/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/wind/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,IAAI,EACJ,WAAW,EACX,SAAS,EACT,eAAe,EACf,mBAAmB,EACnB,gBAAgB,EAChB,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,YAAY,GAClB,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,SAAS,EAAE,mBAAmB,EAAE,KAAK,SAAS,EAAE,KAAK,UAAU,EAAE,MAAM,QAAQ,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Node } from 'three/webgpu';
|
|
2
|
+
import type { WindSource } from './node';
|
|
3
|
+
/**
|
|
4
|
+
* How a tree material's vertices move with the Wind between two Wind times, for Wind-aware velocity
|
|
5
|
+
* (ADR 0011). Registered by Trees and Forests next to their materials' `positionNode`; read only by
|
|
6
|
+
* a scene pass that asks for a velocity channel (`windVelocityMRT` in `@casmo/tree.js/scene`). The
|
|
7
|
+
* materials themselves are never changed for it.
|
|
8
|
+
*/
|
|
9
|
+
export interface WindMotion {
|
|
10
|
+
/** The Wind (or binding) the material sways with: its clock gives the current Wind time. */
|
|
11
|
+
readonly source: WindSource;
|
|
12
|
+
/**
|
|
13
|
+
* TSL node: where each vertex was at Wind time `previous` relative to where it is now, in the
|
|
14
|
+
* space `positionNode` outputs (the shader's `positionLocal`). Only Wind: Growth and Season are
|
|
15
|
+
* the current ones (they are not motion).
|
|
16
|
+
*/
|
|
17
|
+
shift(previous: Node<'float'>): Node<'vec3'>;
|
|
18
|
+
/**
|
|
19
|
+
* TSL node: the current Wind displacement of each vertex, in the space `positionNode` outputs (only
|
|
20
|
+
* attributes and uniforms). Tree Shader Hooks turn the smooth normal with it (the swayed normal).
|
|
21
|
+
*/
|
|
22
|
+
readonly offset?: Node<'vec3'>;
|
|
23
|
+
}
|
|
24
|
+
/** Registers the Wind motion of the materials drawn with `positionNode`. */
|
|
25
|
+
export declare function setWindMotion(positionNode: Node, motion: WindMotion): void;
|
|
26
|
+
/** The Wind motion of a material's `positionNode`, if it is a tree.js tree position. */
|
|
27
|
+
export declare function windMotionOf(positionNode: Node | null | undefined): WindMotion | undefined;
|
|
28
|
+
/** The Wind time (seconds) a source shows at renderer time `frameTime`: its pinned time, or the clock. */
|
|
29
|
+
export declare function windTimeOf(source: WindSource, frameTime: number): number;
|
|
30
|
+
//# sourceMappingURL=motion.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"motion.d.ts","sourceRoot":"","sources":["../../src/wind/motion.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IACzB,4FAA4F;IAC5F,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;IAC5B;;;;OAIG;IACH,KAAK,CAAC,QAAQ,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC;IAC7C;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;CAChC;AAQD,4EAA4E;AAC5E,wBAAgB,aAAa,CAAC,YAAY,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CAE1E;AAED,wFAAwF;AACxF,wBAAgB,YAAY,CAAC,YAAY,EAAE,IAAI,GAAG,IAAI,GAAG,SAAS,GAAG,UAAU,GAAG,SAAS,CAE1F;AAED,0GAA0G;AAC1G,wBAAgB,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM,CAGxE"}
|
package/dist/wind/node.d.ts
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import type { Node, NodeMaterial } from 'three/webgpu';
|
|
2
2
|
import type { WindUniforms } from './Wind';
|
|
3
3
|
import type { WindResponse } from './response';
|
|
4
|
+
import { type WindBurstFrame } from './burst';
|
|
4
5
|
/**
|
|
5
6
|
* Overrides for trees that are not one object each (Forest instances): the Wind direction in
|
|
6
|
-
* the tree's own space and the tree's phase (radians), e.g. from per-instance attributes
|
|
7
|
+
* the tree's own space and the tree's phase (radians), e.g. from per-instance attributes; and the
|
|
8
|
+
* Wind time (seconds) to evaluate the sway at (default the Wind's own clock), e.g. the previous
|
|
9
|
+
* frame's for Wind-aware velocity. `burst`: where the tree stands for Wind Bursts (default the
|
|
10
|
+
* rendered object), or `false` for a tree that does not take Wind Bursts. Burst nodes are only added
|
|
11
|
+
* once the Wind has had a burst (one node-graph rebuild then; see `Wind.burst`).
|
|
7
12
|
*/
|
|
8
13
|
export interface WindFrame {
|
|
9
14
|
direction?: Node<'vec3'>;
|
|
10
15
|
phase?: Node<'float'>;
|
|
16
|
+
time?: Node<'float'>;
|
|
17
|
+
burst?: WindBurstFrame | false;
|
|
11
18
|
}
|
|
12
19
|
/** Anything holding Wind uniforms: a {@link Wind} or a {@link WindBinding} that follows one. */
|
|
13
20
|
export interface WindSource {
|
|
@@ -25,11 +32,18 @@ export declare function objectWindDirection(wind: WindSource): Node<'vec3'>;
|
|
|
25
32
|
* - branches: swing faster, with a phase that varies smoothly in space so joints stay attached,
|
|
26
33
|
* plus a little cross-wind motion;
|
|
27
34
|
* - leaves: flutter along their normal, more at the tip.
|
|
28
|
-
* All of it is scaled by slow gusts. Wind
|
|
35
|
+
* All of it is scaled by slow gusts. Wind Bursts push trunk, branches and leaves the same way, away
|
|
36
|
+
* from each burst point, scaled by the same response (and not by the Wind strength). Wind direction is world space; it is turned into the tree's
|
|
29
37
|
* object space (rotation only, so a scaled-up tree sways proportionally more). `frame` replaces
|
|
30
|
-
* that direction
|
|
38
|
+
* that direction, the response's phase and the Wind time (see {@link WindFrame}).
|
|
31
39
|
*/
|
|
32
40
|
export declare function windOffset(wind: WindSource, response: WindResponse, frame?: WindFrame): Node<'vec3'>;
|
|
41
|
+
/**
|
|
42
|
+
* TSL node: the Wind displacement (vec3, the tree's space) of a whole tree drawn as one picture (an
|
|
43
|
+
* Impostor card), at the tree-space point `point`: the trunk sway of its height (as `aWind.x`:
|
|
44
|
+
* (height / trunk height)², clamped), with the crown's branches swinging along as one. No leaf flutter.
|
|
45
|
+
*/
|
|
46
|
+
export declare function treeSwayOffset(wind: WindSource, response: WindResponse, point: Node<'vec3'>, frame?: WindFrame): Node<'vec3'>;
|
|
33
47
|
/**
|
|
34
48
|
* Adds a Wind offset to a material's vertex position (its existing `positionNode`, or the plain
|
|
35
49
|
* local position). The shadow pass reuses `positionNode`, so shadows sway along.
|
package/dist/wind/node.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/wind/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/wind/node.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAcvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAmD,KAAK,cAAc,EAAE,MAAM,SAAS,CAAC;AAU/F;;;;;;;GAOG;AACH,MAAM,WAAW,SAAS;IACxB,SAAS,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC;IACzB,KAAK,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACtB,IAAI,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACrB,KAAK,CAAC,EAAE,cAAc,GAAG,KAAK,CAAC;CAChC;AAED,gGAAgG;AAChG,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;CACjC;AAED,2FAA2F;AAC3F,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,CAElE;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,GAAE,SAAc,GAAG,IAAI,CAAC,MAAM,CAAC,CAuBxG;AA4DD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,KAAK,GAAE,SAAc,GAAG,IAAI,CAAC,MAAM,CAAC,CAQjI;AAED;;;GAGG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAG5E"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@casmo/tree.js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "Procedural trees for three.js (WebGPURenderer, TSL node materials).",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"three",
|
|
@@ -55,6 +55,14 @@
|
|
|
55
55
|
"types": "./dist/effects/index.d.ts",
|
|
56
56
|
"import": "./dist/effects.js"
|
|
57
57
|
},
|
|
58
|
+
"./scene": {
|
|
59
|
+
"types": "./dist/scene/index.d.ts",
|
|
60
|
+
"import": "./dist/scene.js"
|
|
61
|
+
},
|
|
62
|
+
"./weather": {
|
|
63
|
+
"types": "./dist/weather/index.d.ts",
|
|
64
|
+
"import": "./dist/weather.js"
|
|
65
|
+
},
|
|
58
66
|
"./species": {
|
|
59
67
|
"types": "./dist/species/index.d.ts",
|
|
60
68
|
"import": "./dist/species.js"
|
package/dist/effects.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"effects.js","names":["n"],"sources":["../src/effects/mask.ts","../src/effects/tree-id.ts","../src/effects/screen.ts","../src/effects/inner-lines.ts","../src/effects/pass.ts","../src/effects/outline.ts","../src/effects/glow.ts","../src/effects/grade.ts","../src/effects/highlight.ts","../src/effects/suggested.ts","../src/effects/effects.ts"],"sourcesContent":["import { Vector4, type Camera, type Material, type MRTNode, type Node, type Object3D, type TextureNode } from 'three/webgpu';\nimport { mrt, uniform } from 'three/tsl';\n\n/** Name of the tree mask output in a pass's MRT (`scenePass.getTextureNode(TREE_MASK)`). */\nexport const TREE_MASK = 'treeMask';\n\n/** The part of a tree a material draws. */\nexport type TreePart = 'bark' | 'leaves' | 'fruit';\n\n/**\n * Which tree part a material draws: 'bark', 'leaves' or 'fruit' for tree.js materials (and their clones),\n * `null` for anything else. Tree Effects only change the pixels drawn by these materials.\n */\nexport function treePartOf(material: Material | null | undefined): TreePart | null {\n const part: unknown = material?.userData.treePart;\n return part === 'bark' || part === 'leaves' || part === 'fruit' ? part : null;\n}\n\nfunction isSelected(object: Object3D | null, selection: readonly Object3D[]): boolean {\n for (let o = object; o; o = o.parent) if (selection.includes(o)) return true;\n return false;\n}\n\n/**\n * TSL node: the tree mask value of the object being drawn, `vec4(tree, leaves, selected, 1)`:\n * r = 1 on tree pixels (bark, leaves and Fruit), g = 1 on leaf pixels, b = 1 on pixels of selected trees (the outline's\n * selection), 0 elsewhere. A per-object uniform decided from the drawn material\n * ({@link treePartOf}), so no tree material is changed and every other object writes 0.\n *\n * `selection`: the selected tree objects (Trees, Forests, any ancestor of tree meshes), read on\n * every draw, so it may be changed in place. `null` (default) selects every tree.\n */\nexport function createTreeMask(selection: readonly Object3D[] | null = null): Node<'vec4'> {\n return uniform(new Vector4(0, 0, 0, 1)).onObjectUpdate((frame, self) => {\n const part = treePartOf(frame.material);\n const selected = part !== null && (selection === null || isSelected(frame.object, selection));\n self.value.set(part ? 1 : 0, part === 'leaves' ? 1 : 0, selected ? 1 : 0, 1);\n return undefined;\n });\n}\n\n/**\n * The MRT output that renders the tree mask ({@link createTreeMask}) next to the colour. Merge it\n * into the MRT of your own scene pass: `scenePass.setMRT(mrt({ output, normal: normalView }).merge(treeMaskMRT()))`,\n * then read it with `scenePass.getTextureNode(TREE_MASK)`.\n */\nexport function treeMaskMRT(selection: readonly Object3D[] | null = null): MRTNode {\n const node = mrt({ [TREE_MASK]: createTreeMask(selection) });\n node.setClearColor(TREE_MASK, 0x000000, 0);\n return node;\n}\n\n/** What every Tree Effect reads: the scene colour and the tree mask (screen-space nodes). */\nexport interface TreeEffectInput {\n /** Scene colour (linear, before tone mapping), e.g. `scenePass.getTextureNode('output')`. */\n color: Node<'vec4'>;\n /** Tree mask texture (see {@link createTreeMask}), e.g. `scenePass.getTextureNode(TREE_MASK)`. */\n mask: TextureNode;\n /**\n * Tree ID texture (`r32uint`, see `treeIdMRT`), e.g. `scenePass.getTextureNode(TREE_ID)`; only\n * needed by effects that tell trees apart. Read it with exact texel loads, never filtered.\n */\n treeId?: TextureNode;\n /**\n * Scene depth texture, e.g. `scenePass.getTextureNode('depth')`; only needed by effects that\n * compare distances (the outline's `betweenTrees`, and Inner Lines with `camera`).\n */\n depth?: TextureNode;\n /** The camera the scene pass renders with (its near and far turn `depth` into view Z). */\n camera?: Camera;\n /**\n * View-space normal texture, e.g. `scenePass.getTextureNode('normal')` (see `treeNormalMRT`, or\n * your own normal MRT); only needed by Inner Lines. Encoded as `normalEncoding` says.\n */\n normal?: TextureNode;\n /**\n * How `normal` stores the view normal: `'color'` (default) = `directionToColor(normalView)`, as in\n * an RGBA8 target; `'direction'` = the normal itself, as in a float target.\n */\n normalEncoding?: 'color' | 'direction';\n}\n","import { NearestFilter, NoColorSpace, RedIntegerFormat, UnsignedIntType, Vector2, type BufferAttribute, type MRTNode, type Node, type Object3D, type PassNode, type Renderer, type Texture } from 'three/webgpu';\nimport { instanceIndex, mrt, select, uniform } from 'three/tsl';\nimport type { Forest, ForestTree, ForestVariant } from '../forest';\nimport type { Tree } from '../tree';\nimport { treePartOf } from './mask';\n\n/** Name of the Tree ID output in a pass's MRT (`scenePass.getTextureNode(TREE_ID)`), see {@link treeIdMRT}. */\nexport const TREE_ID = 'treeId';\n\n// The module-wide Tree ID registry (ADR 0009). Holds no strong references to trees. IDs are handed\n// out on first use: by treeIdOf() or by the first draw with the Tree ID channel.\nconst MAX_ID = 0xffffffff;\nlet nextId = 1;\nconst treeIds = new WeakMap<Tree, number>();\nconst treesById = new Map<number, WeakRef<Tree>>();\nconst forgetTree = new FinalizationRegistry<number>((id) => treesById.delete(id));\n\n/**\n * The IDs of one allocation of a Forest Variant's instanced meshes: `base + slot` for each slot\n * up to its capacity. A Variant that grows gets new meshes, and with them a new block.\n */\ninterface Block {\n base: number;\n capacity: number;\n variant: WeakRef<ForestVariant>;\n /** The instance matrix buffer the Variant's meshes shared when the block was reserved. */\n matrices: WeakRef<BufferAttribute>;\n}\nconst blockOf = new WeakMap<BufferAttribute, Block>();\n/** Every live block, by ascending `base`. */\nconst blocks: Block[] = [];\nconst forgetBlock = new FinalizationRegistry<Block>((block) => blocks.splice(blocks.indexOf(block), 1));\n\nfunction reserve(count: number): number {\n if (nextId + count - 1 > MAX_ID) throw new RangeError('Tree IDs exhausted: more than 4294967295 handed out in this session');\n const base = nextId;\n nextId += count;\n return base;\n}\n\nfunction idOfTree(tree: Tree): number {\n let id = treeIds.get(tree);\n if (id === undefined) {\n id = reserve(1);\n treeIds.set(tree, id);\n treesById.set(id, new WeakRef(tree));\n forgetTree.register(tree, id);\n }\n return id;\n}\n\n/** Whether the Variant still draws with the meshes the block was reserved for. */\nfunction isCurrent(block: Block, variant: ForestVariant): boolean {\n return variant.wood.instanceMatrix === block.matrices.deref() && variant.wood.parent !== null;\n}\n\nfunction blockOfVariant(variant: ForestVariant): Block {\n const matrices = variant.wood.instanceMatrix;\n let block = blockOf.get(matrices);\n if (!block) {\n block = { base: reserve(variant.capacity), capacity: variant.capacity, variant: new WeakRef(variant), matrices: new WeakRef(matrices) };\n blockOf.set(matrices, block);\n blocks.push(block);\n forgetBlock.register(matrices, block);\n }\n return block;\n}\n\nfunction blockAt(id: number): Block | undefined {\n let lo = 0;\n let hi = blocks.length - 1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n const block = blocks[mid]!;\n if (id < block.base) hi = mid - 1;\n else if (id >= block.base + block.capacity) lo = mid + 1;\n else return block;\n }\n return undefined;\n}\n\n/**\n * The current Tree ID of a Tree or a Forest tree, or `undefined` for a Forest tree that was removed.\n * IDs are handed out lazily, on first use: by this function or by the first draw with the Tree ID\n * channel, whichever comes first. So asking for a Tree's ID before it is drawn reserves it then\n * (and for a Forest tree the block of its Variant's current meshes). A Forest tree's ID is\n * frame-relative (see {@link treeFromId}).\n */\nexport function treeIdOf(tree: Tree | ForestTree): number | undefined {\n if ('isTree' in tree) return idOfTree(tree);\n const variant = tree.owner;\n if (!variant || tree.slot < 0 || variant.wood.parent === null) return undefined;\n return blockOfVariant(variant).base + tree.slot;\n}\n\n/**\n * The Tree or Forest tree with this Tree ID, resolved against the current trees, or `undefined`\n * for 0 (not a tree), an unknown ID or a tree that is gone.\n */\nexport function treeFromId(id: number): Tree | ForestTree | undefined {\n if (!Number.isInteger(id) || id <= 0) return undefined;\n const tree = treesById.get(id)?.deref();\n if (tree) return tree;\n const block = blockAt(id);\n const variant = block?.variant.deref();\n if (!block || !variant || !isCurrent(block, variant)) return undefined;\n return variant.trees[id - block.base];\n}\n\n/**\n * The ID the drawn object writes: a Tree's ID for each of its parts, the block base of a Forest\n * Variant's mesh (the shader adds the instance index), 0 for anything else.\n */\nfunction drawnId(object: Object3D | null): number {\n for (let o = object; o; o = o.parent) {\n if ((o as Partial<Tree>).isTree) return idOfTree(o as Tree);\n const forest = o.parent as Partial<Forest> | null;\n if (forest?.isForest) {\n const variant = forest.variants!.find((v) => v.meshes.includes(o as never));\n if (variant) return blockOfVariant(variant).base;\n }\n }\n return 0;\n}\n\n/** The parts of three's WebGL2 fallback backend (`renderer.backend`) the Tree ID relies on; not public API. */\ninterface WebGLBackendInternals {\n isWebGLBackend?: boolean;\n gl?: WebGL2RenderingContext;\n has(object: object): boolean;\n get(object: object): { textureGPU?: WebGLTexture; glInternalFormat?: number };\n}\n\n/** The WebGL2 context when `renderer` runs on three's WebGL2 fallback, `undefined` on WebGPU. */\nfunction webglOf(renderer: Renderer): { backend: WebGLBackendInternals; gl: WebGL2RenderingContext } | undefined {\n const backend = renderer.backend as unknown as WebGLBackendInternals;\n return backend.isWebGLBackend === true && backend.gl ? { backend, gl: backend.gl } : undefined;\n}\n\n/** Per Tree ID texture: a framebuffer with just that texture attached, to clear it on its own. */\nconst clearTargets = new WeakMap<Texture, { framebuffer: WebGLFramebuffer; attached: WebGLTexture | null }>();\n\n/**\n * WebGL2 only (a no-op on WebGPU, which clears integer targets correctly): clears the Tree ID\n * texture to 0. three's WebGL2 fallback clears every colour attachment of a render target with\n * `clearBufferfv`, which is invalid for an integer target: the GL ignores it (logging one\n * `GL_INVALID_OPERATION` warning per frame in the console, from three's own clear, that we cannot\n * avoid without three changing its clear) and the IDs of the last frame would stay wherever nothing\n * is drawn now. So this clears the texture with `clearBufferuiv` through a framebuffer of its own,\n * restoring the GL bindings and state it touches, before the scene pass renders (see\n * {@link treeIdTexture}).\n *\n * Depends on three internals: `renderer.backend.gl` (the WebGL2 context) and\n * `renderer.backend.get(texture)` (`textureGPU`, `glInternalFormat`). A texture three has not\n * allocated yet is skipped: new GL storage starts at 0.\n */\nfunction clearTreeIdTextureOnWebGL(renderer: Renderer, texture: Texture): void {\n const webgl = webglOf(renderer);\n if (!webgl || !webgl.backend.has(texture)) return;\n const { gl } = webgl;\n const { textureGPU, glInternalFormat } = webgl.backend.get(texture);\n if (!textureGPU || glInternalFormat !== gl.R32UI) return;\n\n let target = clearTargets.get(texture);\n if (!target) {\n const framebuffer = gl.createFramebuffer();\n target = { framebuffer, attached: null };\n clearTargets.set(texture, target);\n texture.addEventListener('dispose', () => {\n gl.deleteFramebuffer(framebuffer);\n clearTargets.delete(texture);\n });\n }\n const previous = gl.getParameter(gl.DRAW_FRAMEBUFFER_BINDING) as WebGLFramebuffer | null;\n const scissor = gl.isEnabled(gl.SCISSOR_TEST);\n const mask = gl.getParameter(gl.COLOR_WRITEMASK) as [boolean, boolean, boolean, boolean];\n gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, target.framebuffer);\n // three makes a new GL texture when the target is resized: attach the current one.\n if (target.attached !== textureGPU) {\n gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, textureGPU, 0);\n target.attached = textureGPU;\n }\n if (scissor) gl.disable(gl.SCISSOR_TEST);\n gl.colorMask(true, true, true, true);\n gl.clearBufferuiv(gl.COLOR, 0, [0, 0, 0, 0]);\n gl.colorMask(...mask);\n if (scissor) gl.enable(gl.SCISSOR_TEST);\n gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, previous);\n}\n\nconst clearing = new WeakSet<PassNode>();\n\n/**\n * Makes the scene pass clear its Tree ID texture (on WebGL2, see {@link clearTreeIdTextureOnWebGL})\n * right before it renders, every frame, also when nothing is drawn.\n */\nfunction clearTreeIdsBeforeEachRender(scenePass: PassNode, texture: Texture): void {\n if (clearing.has(scenePass)) return;\n clearing.add(scenePass);\n const render = scenePass.updateBefore.bind(scenePass);\n scenePass.updateBefore = (frame) => {\n if (frame.renderer) clearTreeIdTextureOnWebGL(frame.renderer, texture);\n return render(frame);\n };\n}\n\n/**\n * TSL node: the Tree ID of the tree being drawn (`uint`), 0 for anything that is not a tree. A Tree\n * writes one ID for all its parts (wood, leaves, Fruit); a Forest tree writes its Variant's block\n * base + its instance index. A per-object uniform decided from the drawn object, so no material is\n * changed. It ignores the outline's `selection`: every tree gets its ID.\n */\nfunction createTreeId(): Node<'uint'> {\n const base = uniform(0, 'uint').onObjectUpdate((frame, node) => {\n node.value = treePartOf(frame.material) === null ? 0 : drawnId(frame.object);\n return undefined;\n });\n return select(base.equal(0), base, base.add(instanceIndex)) as Node<'uint'>;\n}\n\n/**\n * The MRT output that renders each tree's Tree ID ({@link createTreeId}) next to the colour, opt-in\n * next to {@link treeMaskMRT}. Merge it into the MRT of your own scene pass and always call\n * {@link treeIdTexture} on that pass afterwards:\n * `scenePass.setMRT(mrt({ output }).merge(treeMaskMRT()).merge(treeIdMRT())); treeIdTexture(scenePass);`.\n * Note that this turns MSAA off on that scene pass (an integer target cannot be multisampled, see\n * {@link treeIdTexture}). Read IDs back with {@link readTreeId}, or in a shader with exact texel\n * loads (never filtered).\n */\nexport function treeIdMRT(): MRTNode {\n const node = mrt({ [TREE_ID]: createTreeId() });\n node.setClearColor(TREE_ID, 0x000000, 0);\n return node;\n}\n\n/**\n * Makes the Tree ID target of a scene pass ({@link treeIdMRT} merged into its MRT) one 32-bit\n * unsigned integer per pixel (`r32uint`, read without filtering) and returns its texture. Call it\n * once after `setMRT`, before the first render.\n *\n * **MSAA is turned off on this scene pass**: an integer target cannot be multisampled, and all the\n * targets of a pass share one sample count, so this sets `scenePass.options.samples = 0`, also with\n * an `antialias: true` renderer (the colour then has aliased edges unless you add FXAA/SMAA after\n * the pass). That is a hard constraint of WebGPU and WebGL2, not a choice of tree.js.\n *\n * On the WebGL2 fallback it also makes the pass clear the Tree ID target to 0 right before every\n * render (three cannot clear integer targets there), so a pixel where nothing is drawn reads 0.\n */\nexport function treeIdTexture(scenePass: PassNode): Texture {\n scenePass.options.samples = 0;\n const texture = scenePass.getTexture(TREE_ID);\n texture.format = RedIntegerFormat;\n texture.type = UnsignedIntType;\n texture.minFilter = texture.magFilter = NearestFilter;\n texture.generateMipmaps = false;\n texture.colorSpace = NoColorSpace;\n clearTreeIdsBeforeEachRender(scenePass, texture);\n return texture;\n}\n\n/**\n * Reads the Tree ID under a point of the canvas from the last render of `scenePass` (with\n * {@link treeIdMRT} in its MRT): `x`, `y` in CSS pixels from the canvas's top left corner, as in\n * `event.offsetX/offsetY`. Resolves to 0 off the canvas or where no tree is drawn. Resolve the ID\n * with {@link treeFromId} right away: IDs are frame-relative.\n */\nexport async function readTreeId(renderer: Renderer, scenePass: PassNode, x: number, y: number): Promise<number> {\n const texture = scenePass.getTexture(TREE_ID);\n const target = scenePass.renderTarget;\n const index = target.textures.indexOf(texture);\n if (index < 0) throw new Error('readTreeId: the scene pass has no Tree ID target; merge treeIdMRT() into its MRT');\n const css = renderer.getSize(new Vector2());\n const px = Math.floor((x * target.width) / css.x);\n const py = Math.floor((y * target.height) / css.y);\n if (!(px >= 0 && py >= 0 && px < target.width && py < target.height)) return 0;\n // WebGL reads with the origin at the bottom left, WebGPU at the top left.\n const flipY = webglOf(renderer) !== undefined;\n const data = await renderer.readRenderTargetPixelsAsync(target, px, flipY ? target.height - 1 - py : py, 1, 1, index);\n return Number(data[0] ?? 0);\n}\n","// Screen-space helpers shared by the Tree Effects (internal, not exported from the package).\nimport type { Camera, Node, NodeBuilder, TextureNode } from 'three/webgpu';\nimport { Fn, ivec2, logarithmicDepthToViewZ, orthographicDepthToViewZ, perspectiveDepthToViewZ, screenCoordinate, textureSize, uint, uniform, vec2 } from 'three/tsl';\n\nconst DIAGONAL = Math.SQRT1_2;\n/** Eight sample directions around a pixel, unit length: the four axes and the four diagonals. */\nexport const EIGHT_DIRECTIONS: readonly (readonly [number, number])[] = [\n [1, 0], [-1, 0], [0, 1], [0, -1],\n [DIAGONAL, DIAGONAL], [DIAGONAL, -DIAGONAL], [-DIAGONAL, DIAGONAL], [-DIAGONAL, -DIAGONAL],\n];\n/** Four sample directions around a pixel: the axes. */\nexport const FOUR_DIRECTIONS: readonly (readonly [number, number])[] = [[1, 0], [-1, 0], [0, 1], [0, -1]];\n\n/** The size of a texture in pixels, as a `vec2`. */\nexport function sizeOf(texture: TextureNode): Node<'vec2'> {\n return vec2(textureSize(texture) as unknown as Node<'ivec2'>);\n}\n\n/**\n * The texel `offset` px from the pixel being shaded, clamped to the texture, for exact texel loads\n * (`texture.load(texelAt(texture, offset))`) of unfiltered targets such as the Tree ID.\n */\nexport function texelAt(texture: TextureNode, offset: Node<'vec2'>): Node<'ivec2'> {\n return ivec2(screenCoordinate.xy.add(offset).floor().clamp(vec2(0), sizeOf(texture).sub(1)));\n}\n\n/** The Tree ID at a texel (see {@link texelAt}): 0 where no tree is drawn. */\nexport function treeIdAt(treeId: TextureNode, texel: Node<'ivec2'>): Node<'uint'> {\n return uint(treeId.load(texel).x);\n}\n\n/** An optional input an effect needs, or an error naming the effect, the input and where to get it. */\nexport function requireInput<T>(effect: string, value: T | undefined, name: string, hint: string): T {\n if (value === undefined) throw new Error(`${effect} needs the \\`${name}\\` input: ${hint}`);\n return value;\n}\n\n/**\n * Whether the scene depth `depth` is further from the camera than `than` (both raw values of the\n * scene pass's depth texture). Decided per renderer when the shader is built: a reversed depth\n * buffer (`reversedDepthBuffer`) stores 1 at the near plane and 0 at the far plane, a standard or\n * logarithmic one the other way around.\n */\nexport const isFurther = Fn(([depth, than]: [Node<'float'>, Node<'float'>], builder: NodeBuilder) =>\n builder.renderer.reversedDepthBuffer === true ? depth.lessThan(than) : depth.greaterThan(than),\n) as unknown as (depth: Node<'float'>, than: Node<'float'>) => Node<'bool'>;\n\n/**\n * A function turning a raw value of the scene pass's depth texture into view Z (negative, in world\n * units) for `camera` (its near and far are read every render). It follows the renderer's depth\n * buffer: standard, reversed (`reversedDepthBuffer`) or logarithmic (`logarithmicDepthBuffer`,\n * which three only applies to perspective cameras).\n */\nexport function viewZFromDepth(camera: Camera): (depth: Node<'float'>) => Node<'float'> {\n const lens = camera as Camera & { near: number; far: number; isOrthographicCamera?: boolean };\n const near = uniform(0).onRenderUpdate((_, node) => {\n node.value = lens.near;\n return undefined;\n });\n const far = uniform(0).onRenderUpdate((_, node) => {\n node.value = lens.far;\n return undefined;\n });\n const orthographic = lens.isOrthographicCamera === true;\n // orthographicDepthToViewZ and perspectiveDepthToViewZ handle the reversed depth buffer themselves.\n const convert = Fn(([depth]: [Node<'float'>], builder: NodeBuilder) => {\n if (orthographic) return orthographicDepthToViewZ(depth, near, far);\n if (builder.renderer.logarithmicDepthBuffer === true) return logarithmicDepthToViewZ(depth, near, far);\n return perspectiveDepthToViewZ(depth, near, far);\n });\n return (depth) => convert(depth) as unknown as Node<'float'>;\n}\n","import { Color, type ColorRepresentation, type MRTNode, type Node } from 'three/webgpu';\nimport { abs, dot, float, max, mix, mrt, normalView, packNormalToRGB, smoothstep, uniform, unpackRGBToNormal, uv, vec2, vec4 } from 'three/tsl';\nimport type { LiveTreeEffect } from './live';\nimport type { TreeEffectInput } from './mask';\nimport { FOUR_DIRECTIONS, requireInput, sizeOf, viewZFromDepth } from './screen';\n\n/** Name of the view normal output in a pass's MRT (`scenePass.getTextureNode('normal')`), see {@link treeNormalMRT}. */\nexport const TREE_NORMAL = 'normal';\n\n/**\n * The MRT output that renders view normals in the `'color'` encoding (`packNormalToRGB(normalView)`,\n * the same as `directionToColor`) to a target named `normal`, for Inner Lines. Merge it into the MRT\n * of your own scene pass and make the target RGBA8:\n * `scenePass.setMRT(mrt({ output }).merge(treeMaskMRT()).merge(treeNormalMRT())); scenePass.getTexture('normal').type = UnsignedByteType;`.\n * If your pipeline already renders normals (GTAO, SSR), pass that texture as the `normal` input instead.\n */\nexport function treeNormalMRT(): MRTNode {\n return mrt({ [TREE_NORMAL]: packNormalToRGB(normalView) });\n}\n\n/** Inner Lines settings. */\nexport interface InnerLinesOptions {\n /** Line colour (default a dark green-brown). */\n color?: ColorRepresentation;\n /** How far apart (in pixels) the compared pixels are, which sets the line width (default 1). */\n thickness?: number;\n /** Opacity of the lines, 0..1 (default 1). */\n strength?: number;\n /** A line where the normals of neighbouring pixels differ by more than this, as 1 − dot (default 0.4). */\n normalThreshold?: number;\n /** A line where neighbouring pixels step away by more than this, as relative depth |Δz| / z (default 0.02). */\n depthThreshold?: number;\n}\n\n/**\n * Tree Effect: ink lines inside the trees where the surface folds (normal edges) or steps away\n * from the viewer (depth edges), such as around each leaf clump. Only drawn on tree pixels (of\n * every tree, regardless of the outline's `selection`), and only from neighbours that are tree\n * pixels too: the silhouette is left to the outline. Needs the `depth`, `camera` and `normal` inputs\n * (`treeEffectsPass(scene, camera, null, { normal: true })` has them) and throws without them.\n * Works with a standard, reversed (`reversedDepthBuffer`) or logarithmic (`logarithmicDepthBuffer`)\n * depth buffer, and with perspective and orthographic cameras.\n */\nexport function innerLines(input: TreeEffectInput, options: InnerLinesOptions = {}): Node<'vec4'> {\n return liveInnerLines(input, options).node;\n}\n\n/** {@link innerLines} with its settings as uniforms; the normal encoding is fixed when built. */\nexport function liveInnerLines(input: TreeEffectInput, options: InnerLinesOptions = {}): LiveTreeEffect<InnerLinesOptions> {\n const normal = requireInput('innerLines', input.normal, 'normal', \"view normals, e.g. treeNormalMRT() or your own normal MRT (with `normalEncoding`)\");\n const depth = requireInput('innerLines', input.depth, 'depth', \"the scene pass's depth, scenePass.getTextureNode('depth')\");\n const camera = requireInput('innerLines', input.camera, 'camera', 'the camera the scene pass renders with');\n\n const color = uniform(new Color());\n const thickness = uniform(0);\n const strength = uniform(0);\n const normalLow = uniform(0);\n const normalHigh = uniform(0);\n const depthLow = uniform(0);\n const depthHigh = uniform(0);\n const update = (o: InnerLinesOptions): void => {\n const n = o.normalThreshold ?? 0.4;\n const d = o.depthThreshold ?? 0.02;\n color.value.set(o.color ?? '#1d2a14');\n thickness.value = o.thickness ?? 1;\n strength.value = o.strength ?? 1;\n // A soft step around each threshold, so lines fade in rather than flicker.\n normalLow.value = n * 0.75;\n normalHigh.value = n * 1.25;\n depthLow.value = d * 0.5;\n depthHigh.value = d * 1.5;\n };\n update(options);\n\n // View Z for the relative depth step; follows a standard, reversed or logarithmic depth buffer.\n const toViewZ = viewZFromDepth(camera);\n const viewZ = (at: Node<'vec2'>): Node<'float'> => toViewZ(depth.sample(at).r);\n const direction = input.normalEncoding === 'direction';\n const normalAt = (at: Node<'vec2'>): Node<'vec3'> => {\n const n = normal.sample(at).rgb;\n return (direction ? n : unpackRGBToNormal(n)).normalize() as Node<'vec3'>;\n };\n\n const { mask } = input;\n const step = vec2(thickness).div(sizeOf(mask));\n const centre = uv();\n const n0 = normalAt(centre);\n const z0 = viewZ(centre);\n let edge: Node<'float'> = float(0);\n for (const [x, y] of FOUR_DIRECTIONS) {\n const at = centre.add(step.mul(vec2(x, y)));\n const normalEdge = smoothstep(normalLow, normalHigh, float(1).sub(dot(n0, normalAt(at))));\n const depthEdge = smoothstep(depthLow, depthHigh, abs(viewZ(at).sub(z0)).div(abs(z0)));\n // Only neighbours that are tree pixels count: the silhouette is the outline's.\n edge = max(edge, max(normalEdge, depthEdge).mul(mask.sample(at).r));\n }\n const line = edge.mul(mask.sample(centre).r).mul(strength);\n return { node: vec4(mix(input.color.rgb, color, line), input.color.a), update };\n}\n","import { UnsignedByteType, type Camera, type Object3D, type PassNode, type Scene } from 'three/webgpu';\nimport { mrt, output, pass } from 'three/tsl';\nimport { TREE_MASK, treeMaskMRT, type TreeEffectInput } from './mask';\nimport { TREE_ID, treeIdMRT, treeIdTexture } from './tree-id';\nimport { TREE_NORMAL, treeNormalMRT } from './inner-lines';\n\n/**\n * The opt-in extra channels of a scene pass, next to the colour and the tree mask (which are always\n * there). Each one adds an MRT target, so leave them off unless an effect (or picking) needs them.\n */\nexport interface TreeEffectsChannels {\n /**\n * The Tree ID target (`treeIdMRT`), for effects that tell trees apart and for picking. Turns MSAA\n * off on the scene pass (see `treeIdTexture`).\n */\n treeId?: boolean;\n /** The view normal target (`treeNormalMRT`, RGBA8, the 'color' encoding), for Inner Lines. */\n normal?: boolean;\n}\n\n/** A scene pass that renders the colour, the tree mask and the chosen channels, ready for the Tree Effects. */\nexport interface TreeEffectsPass extends TreeEffectInput {\n pass: PassNode;\n}\n\n/**\n * Creates `pass(scene, camera)` with MRT `{ output, treeMask }` (plus the opt-in `channels`, e.g.\n * `{ treeId: true }`, `{ normal: true }`) and returns it with the texture nodes of every target (and the depth and camera) as the effects' inputs.\n * `selection`: the trees to outline (default `null` = all trees), see `createTreeMask`. If your\n * pipeline already has a scene pass, merge `treeMaskMRT` (and `treeIdMRT`) into it instead.\n */\nexport function treeEffectsPass(\n scene: Scene,\n camera: Camera,\n selection: readonly Object3D[] | null = null,\n channels: TreeEffectsChannels = {},\n): TreeEffectsPass {\n const scenePass = pass(scene, camera);\n let outputs = mrt({ output }).merge(treeMaskMRT(selection));\n if (channels.treeId) outputs = outputs.merge(treeIdMRT());\n if (channels.normal) outputs = outputs.merge(treeNormalMRT());\n scenePass.setMRT(outputs);\n scenePass.getTexture(TREE_MASK).type = UnsignedByteType;\n const input: TreeEffectsPass = {\n pass: scenePass,\n color: scenePass.getTextureNode('output'),\n mask: scenePass.getTextureNode(TREE_MASK),\n depth: scenePass.getTextureNode('depth'),\n camera,\n };\n if (channels.treeId) {\n treeIdTexture(scenePass);\n input.treeId = scenePass.getTextureNode(TREE_ID);\n }\n if (channels.normal) {\n scenePass.getTexture(TREE_NORMAL).type = UnsignedByteType;\n input.normal = scenePass.getTextureNode(TREE_NORMAL);\n input.normalEncoding = 'color';\n }\n return input;\n}\n","import { Color, type ColorRepresentation, type Node } from 'three/webgpu';\nimport { float, max, mix, select, uint, uniform, uv, vec2, vec4 } from 'three/tsl';\nimport type { LiveTreeEffect } from './live';\nimport type { TreeEffectInput } from './mask';\nimport { EIGHT_DIRECTIONS, isFurther, requireInput, sizeOf, texelAt, treeIdAt } from './screen';\n\n/** Tree outline settings. */\nexport interface TreeOutlineOptions {\n /** Line colour (default a dark green-brown). */\n color?: ColorRepresentation;\n /** Line width in pixels (default 2). */\n thickness?: number;\n /** Opacity of the line, 0..1 (default 1). */\n strength?: number;\n /**\n * Also draw the line between overlapping trees (Tree–Tree, Forest tree–Forest tree, Tree–Forest\n * tree): on a selected tree pixel next to another tree that is further away, so the line lies on\n * the front tree's side, as thick as the outer outline (with a standard, reversed or logarithmic\n * depth buffer). Needs the `treeId` and `depth` inputs (see `treeEffectsPass`). Default false.\n * Changing it builds a new graph.\n */\n betweenTrees?: boolean;\n}\n\n/**\n * Tree Effect: an outline along the silhouettes of the selected trees (the `selection` of the\n * tree mask, see `createTreeMask`; all trees by default), around the outside of the canopy and\n * the gaps in it. The line is drawn on the inside of the silhouette, so only tree pixels change.\n * With `betweenTrees`, it is also drawn where a tree overlaps another one behind it.\n */\nexport function treeOutline(input: TreeEffectInput, options: TreeOutlineOptions = {}): Node<'vec4'> {\n return liveTreeOutline(input, options).node;\n}\n\n/** {@link treeOutline} with its settings as uniforms. */\nexport function liveTreeOutline(input: TreeEffectInput, options: TreeOutlineOptions = {}): LiveTreeEffect<TreeOutlineOptions> {\n const color = uniform(new Color());\n const thickness = uniform(0);\n const strength = uniform(0);\n const update = (o: TreeOutlineOptions): void => {\n color.value.set(o.color ?? '#1d2a14');\n thickness.value = o.thickness ?? 2;\n strength.value = o.strength ?? 1;\n };\n update(options);\n\n const { mask } = input;\n const step = vec2(thickness).div(sizeOf(mask));\n const centre = uv();\n // Fraction of neighbours (at `thickness` px) that are not selected tree pixels.\n // With betweenTrees, a neighbour of another tree that is further away counts as outside too.\n const behind = options.betweenTrees === true ? otherTreeBehind(input, thickness) : null;\n let outside: Node<'float'> = float(0);\n for (const [x, y] of EIGHT_DIRECTIONS) {\n const notSelected = float(1).sub(mask.sample(centre.add(step.mul(vec2(x, y)))).b);\n outside = outside.add(behind ? max(notSelected, behind(x, y)) : notSelected);\n }\n const edge = outside.mul(3 / EIGHT_DIRECTIONS.length).clamp(0, 1).mul(mask.sample(centre).b).mul(strength);\n return { node: vec4(mix(input.color.rgb, color, edge), input.color.a), update };\n}\n\n/**\n * For `betweenTrees`: a function giving, per direction, 1 where the neighbour at `thickness` px is a\n * different tree (another nonzero Tree ID) that is further from the camera than this pixel, 0\n * elsewhere, so the line lies on the front tree's side. IDs and depths are read with exact texel\n * loads; \"further\" follows the renderer's depth buffer (standard, reversed or logarithmic).\n */\nfunction otherTreeBehind(input: TreeEffectInput, thickness: Node<'float'>): (x: number, y: number) => Node<'float'> {\n const how = 'use treeEffectsPass(scene, camera, selection, { treeId: true }), which has both';\n const treeId = requireInput('treeOutline with betweenTrees', input.treeId, 'treeId', how);\n const depth = requireInput('treeOutline with betweenTrees', input.depth, 'depth', how);\n const here = texelAt(treeId, vec2(0));\n const id = treeIdAt(treeId, here);\n const z = depth.load(here).x;\n return (x, y) => {\n const there = texelAt(treeId, vec2(x, y).mul(thickness));\n const other = treeIdAt(treeId, there);\n const further = isFurther(depth.load(there).x, z);\n return select(other.notEqual(uint(0)).and(other.notEqual(id)).and(further), float(1), float(0));\n };\n}\n","import { Color, type ColorRepresentation, type Node } from 'three/webgpu';\nimport { luminance, smoothstep, uniform, vec4 } from 'three/tsl';\nimport { gaussianBlur } from 'three/addons/tsl/display/GaussianBlurNode.js';\nimport type { LiveTreeEffect } from './live';\nimport type { TreeEffectInput } from './mask';\n\n/** Leaf glow settings. */\nexport interface LeafGlowOptions {\n /** Glow colour, multiplied with the blurred leaf colour (default white). */\n color?: ColorRepresentation;\n /** Glow strength (default 0.6). */\n intensity?: number;\n /** Only leaf pixels brighter than this (linear luminance) glow; 0 = all leaves (default 0.15). */\n threshold?: number;\n /** Blur radius (Gaussian sigma, in pixels at half resolution; default 6). */\n radius?: number;\n}\n\n/** The blur radius of leaf glow settings (part of a Tree Effects graph's shape). */\nexport function glowRadius(options: LeafGlowOptions): number {\n return options.radius ?? 6;\n}\n\n/**\n * Tree Effect: a soft glow of the leaves. The bright (sunlit) leaf pixels are blurred and added\n * back onto the tree pixels (leaves and the wood between them), never onto the rest of the scene.\n */\nexport function leafGlow(input: TreeEffectInput, options: LeafGlowOptions = {}): Node<'vec4'> {\n return liveLeafGlow(input, options).node;\n}\n\n/** {@link leafGlow} with its settings as uniforms; `radius` is fixed when built. */\nexport function liveLeafGlow(input: TreeEffectInput, options: LeafGlowOptions = {}): LiveTreeEffect<LeafGlowOptions> {\n const color = uniform(new Color());\n const intensity = uniform(0);\n const low = uniform(0);\n const high = uniform(0);\n const update = (o: LeafGlowOptions): void => {\n const threshold = o.threshold ?? 0.15;\n color.value.set(o.color ?? '#ffffff');\n intensity.value = o.intensity ?? 0.6;\n low.value = threshold;\n high.value = threshold * 2 + 0.05;\n };\n update(options);\n\n const bright = smoothstep(low, high, luminance(input.color.rgb));\n const leaves = vec4(input.color.rgb.mul(input.mask.g).mul(bright), 1);\n const blurred = gaussianBlur(leaves, null, glowRadius(options), { resolutionScale: 0.5 });\n const glow = blurred.rgb.mul(color).mul(intensity).mul(input.mask.r);\n return { node: vec4(input.color.rgb.add(glow), input.color.a), update };\n}\n","import { Color, type ColorRepresentation, type Node } from 'three/webgpu';\nimport { luminance, mix, select, uniform, vec3, vec4 } from 'three/tsl';\nimport type { LiveTreeEffect } from './live';\nimport type { TreeEffectInput } from './mask';\n\n/** Tree colour grading settings (all optional; the defaults change nothing). */\nexport interface TreeColorGradeOptions {\n /** Brightness multiplier (default 1). */\n exposure?: number;\n /** 0 = grey, 1 = unchanged (default), > 1 = more saturated. */\n saturation?: number;\n /** Contrast around mid grey: 1 = unchanged (default), > 1 = more contrast. */\n contrast?: number;\n /** Colour multiplied in, e.g. a warm '#fff2dd' (default white). */\n tint?: ColorRepresentation;\n}\n\nconst MID_GREY = 0.18; // linear\n\n/**\n * Tree Effect: colour grading (exposure, tint, saturation, contrast) of the tree pixels only.\n * Returns the graded colour where the tree mask is set and `input.color` unchanged elsewhere.\n */\nexport function treeColorGrade(input: TreeEffectInput, options: TreeColorGradeOptions = {}): Node<'vec4'> {\n return liveTreeColorGrade(input, options).node;\n}\n\n/** {@link treeColorGrade} with its settings as uniforms. */\nexport function liveTreeColorGrade(input: TreeEffectInput, options: TreeColorGradeOptions = {}): LiveTreeEffect<TreeColorGradeOptions> {\n const tint = uniform(new Color());\n const exposure = uniform(0);\n const saturation = uniform(0);\n const contrast = uniform(0);\n const update = (o: TreeColorGradeOptions): void => {\n tint.value.set(o.tint ?? '#ffffff');\n exposure.value = o.exposure ?? 1;\n saturation.value = o.saturation ?? 1;\n contrast.value = o.contrast ?? 1;\n };\n update(options);\n\n const tinted = input.color.rgb.mul(tint).mul(exposure);\n const saturated = mix(vec3(luminance(tinted)), tinted, saturation).max(0);\n const contrasted = saturated.div(MID_GREY).pow(vec3(contrast)).mul(MID_GREY);\n const node = select(input.mask.r.greaterThan(0.5), vec4(contrasted, input.color.a), input.color);\n return { node, update };\n}\n","import { Color, type ColorRepresentation, type Node } from 'three/webgpu';\nimport { Break, float, Fn, If, Loop, max, mix, select, time, uint, uniform, uniformArray, vec2, vec4 } from 'three/tsl';\nimport type { ForestTree } from '../forest';\nimport type { Tree } from '../tree';\nimport type { LiveTreeEffect } from './live';\nimport type { TreeEffectInput } from './mask';\nimport { EIGHT_DIRECTIONS, requireInput, texelAt, treeIdAt } from './screen';\nimport { treeIdOf } from './tree-id';\n\n/** Highlight settings. */\nexport interface TreeHighlightOptions {\n /** Colour the highlighted trees are tinted towards (default a warm yellow, '#ffe066'). */\n color?: ColorRepresentation;\n /** How far the trees are tinted towards `color`, 0..1 (default 0.25). */\n tint?: number;\n /** Brightness multiplier of the highlighted trees (default 1.25). */\n brightness?: number;\n /** Colour of the ring just outside the highlighted trees (default '#ffd23f'). */\n outlineColor?: ColorRepresentation;\n /** Width of the ring in pixels (default 2). */\n thickness?: number;\n /** Opacity of the whole Highlight, 0..1 (default 1). */\n strength?: number;\n /**\n * Pulse frequency in Hz: tint and brightness swing between their value and half of it (half the\n * brightening); the ring stays solid. Default 0 = no pulse.\n */\n pulse?: number;\n}\n\n/** The most trees highlighted at once; the rest of the list is ignored (with one console warning). */\nconst MAX_HIGHLIGHTED = 64;\n\n/**\n * The current Tree ID of a highlighted entry, or `undefined` to skip it: a removed or undrawn\n * Forest tree, a Tree that is disposed or in no scene, or anything that is not a Tree or Forest tree.\n */\nfunction idOfHighlighted(entry: Tree | ForestTree): number | undefined {\n if (!entry || typeof entry !== 'object') return undefined;\n if ('isTree' in entry) return entry.isTree && entry.parent !== null ? treeIdOf(entry) : undefined;\n if (!('slot' in entry) || !('owner' in entry)) return undefined;\n return treeIdOf(entry);\n}\n\n/**\n * Tree Effect: marks the trees in `highlighted` (Trees and Forest trees; mutable, read every frame)\n * by brightening and tinting their pixels and drawing a ring just outside them, the one Tree Effect\n * that also changes pixels next to a tree. At most 64 trees (the rest is ignored with one warning); removed, disposed\n * and undrawn trees are skipped. Needs the Tree ID input (`treeEffectsPass` with `{ treeId: true }`).\n */\nexport function treeHighlight(input: TreeEffectInput, highlighted: readonly (Tree | ForestTree)[], options: TreeHighlightOptions = {}): Node<'vec4'> {\n return liveTreeHighlight(input, highlighted, options).node;\n}\n\n/** {@link treeHighlight} with its settings as uniforms. */\nexport function liveTreeHighlight(\n input: TreeEffectInput,\n highlighted: readonly (Tree | ForestTree)[],\n options: TreeHighlightOptions = {},\n): LiveTreeEffect<TreeHighlightOptions> {\n const treeId = requireInput(\n 'treeHighlight',\n input.treeId,\n 'treeId',\n 'use treeEffectsPass(scene, camera, selection, { treeId: true }), or merge treeIdMRT() into your scene pass and pass its texture node',\n );\n\n const color = uniform(new Color());\n const outlineColor = uniform(new Color());\n const tint = uniform(0);\n const brightness = uniform(0);\n const thickness = uniform(0);\n const strength = uniform(0);\n const pulse = uniform(0);\n const update = (o: TreeHighlightOptions): void => {\n color.value.set(o.color ?? '#ffe066');\n outlineColor.value.set(o.outlineColor ?? '#ffd23f');\n tint.value = o.tint ?? 0.25;\n brightness.value = o.brightness ?? 1.25;\n thickness.value = o.thickness ?? 2;\n strength.value = o.strength ?? 1;\n pulse.value = o.pulse ?? 0;\n };\n update(options);\n\n // The IDs of the highlighted trees, refreshed once before every render (by whichever of the two\n // uniforms is updated first; the array is copied to its buffer after its own refresh).\n const count = uniform(0, 'uint');\n const ids = uniformArray(new Array<number>(MAX_HIGHLIGHTED).fill(0), 'uint');\n let refreshed = -1;\n let warned = false;\n const refresh = (renderId: number): void => {\n if (renderId === refreshed) return;\n refreshed = renderId;\n let n = 0;\n for (const entry of highlighted) {\n const id = idOfHighlighted(entry);\n if (id === undefined) continue;\n if (n === MAX_HIGHLIGHTED) {\n if (!warned) console.warn(`Highlight: at most ${MAX_HIGHLIGHTED} trees are highlighted at once; the rest are ignored`);\n warned = true;\n break;\n }\n ids.array[n++] = id;\n }\n ids.array.fill(0, n);\n count.value = n;\n };\n count.onRenderUpdate((frame) => {\n refresh(frame.renderId);\n return undefined;\n });\n ids.onRenderUpdate((frame) => refresh(frame.renderId));\n\n /** 1 where the tree drawn at `offset` px from this pixel is highlighted, else 0. */\n const isHighlighted = Fn(([offset]: [Node<'vec2'>]) => {\n const id = treeIdAt(treeId, texelAt(treeId, offset));\n const hit = float(0).toVar();\n If(id.notEqual(uint(0)), () => {\n Loop({ start: uint(0), end: count, type: 'uint', condition: '<' }, ({ i }) => {\n If((ids.element(i) as unknown as Node<'uint'>).equal(id), () => {\n hit.assign(1);\n Break();\n });\n });\n });\n return hit;\n });\n\n // The ring: pixels that are not highlighted themselves next to (at `thickness` px) one that is.\n const onHighlighted = isHighlighted(vec2(0));\n let besideHighlighted: Node<'float'> = float(0);\n for (const [x, y] of EIGHT_DIRECTIONS) besideHighlighted = max(besideHighlighted, isHighlighted(vec2(x, y).mul(thickness).round()));\n const ring = besideHighlighted.mul(float(1).sub(onHighlighted));\n\n // 1 without a pulse, else swinging between 1 and 0.5 with a sine.\n const swing = float(0.75).add(float(0.25).mul(time.mul(pulse).mul(2 * Math.PI).cos()));\n const lifted = input.color.rgb.mul(float(1).add(brightness.sub(1).mul(swing)));\n const marked = mix(lifted, color, tint.mul(swing).clamp(0, 1));\n const rgb = mix(input.color.rgb, marked, onHighlighted.mul(strength));\n const node = vec4(mix(rgb, outlineColor, ring.mul(strength)), input.color.a);\n // Nothing highlighted: the colour as it is.\n return { node: select(count.equal(uint(0)), input.color, node), update };\n}\n","import type { StyleName } from '../styles/registry';\nimport type { TreeColorGradeOptions } from './grade';\nimport type { LeafGlowOptions } from './glow';\nimport type { TreeHighlightOptions } from './highlight';\nimport type { TreeOutlineOptions } from './outline';\nimport type { InnerLinesOptions } from './inner-lines';\n\n/** A combination of Tree Effects; leave an effect out to skip it. `{}` = no effects. */\nexport interface TreeEffectsSettings {\n grade?: TreeColorGradeOptions;\n glow?: LeafGlowOptions;\n outline?: TreeOutlineOptions;\n innerLines?: InnerLinesOptions;\n /** Marks the TreeEffects' `highlighted` trees; never in a suggestion. */\n highlight?: TreeHighlightOptions;\n}\n\n/** The suggested combination of Tree Effects for each built-in Style. */\nexport const SUGGESTED_TREE_EFFECTS: Record<StyleName, TreeEffectsSettings> = {\n // Crisp facets: a dark ink line around and between the trees, ink lines on the clumps inside the\n // crown and slightly punchier colours.\n 'low-poly': {\n grade: { saturation: 1.15, contrast: 1.1 },\n innerLines: { color: '#18230f', thickness: 1, strength: 0.8 },\n outline: { color: '#18230f', thickness: 2, strength: 0.9, betweenTrees: true },\n },\n // Storybook look: soft glowing foliage, a warm tint, a hint of ink inside the crown and a soft\n // coloured outline.\n stylized: {\n grade: { saturation: 0.95, contrast: 1.08, tint: '#fff1e0' },\n glow: { color: '#fff6c8', intensity: 0.45, threshold: 0.3, radius: 8 },\n innerLines: { color: '#2b3a1c', thickness: 1, strength: 0.45, normalThreshold: 0.5 },\n outline: { color: '#2b3a1c', thickness: 2, strength: 0.6 },\n },\n // Natural: no ink; only a gentle grade (warmer, a touch more contrast) and a faint sunlit leaf glow.\n realistic: {\n grade: { exposure: 1.05, contrast: 1.08, saturation: 0.95, tint: '#fff5e6' },\n glow: { color: '#e8ffc0', intensity: 0.35, threshold: 0.12, radius: 4 },\n },\n};\n","import { RenderPipeline, type Camera, type Node, type Object3D, type Renderer, type Scene } from 'three/webgpu';\nimport type { StyleName } from '../styles/registry';\nimport { glowRadius, liveLeafGlow } from './glow';\nimport { liveTreeColorGrade } from './grade';\nimport type { LiveTreeEffect } from './live';\nimport type { TreeEffectInput } from './mask';\nimport { liveTreeHighlight } from './highlight';\nimport { liveTreeOutline } from './outline';\nimport { liveInnerLines } from './inner-lines';\nimport { treeEffectsPass, type TreeEffectsChannels, type TreeEffectsPass } from './pass';\nimport { SUGGESTED_TREE_EFFECTS, type TreeEffectsSettings } from './suggested';\nimport { readTreeId, treeFromId } from './tree-id';\nimport type { ForestTree } from '../forest';\nimport type { Tree } from '../tree';\n\n/**\n * Applies a combination of Tree Effects to `input` and returns the resulting colour node, for use in\n * your own post-processing pipeline (`pipeline.outputNode = applyTreeEffects(...)`, or feed it into\n * more effects). Order: colour grade, leaf glow, inner lines, outline, highlight (always on top).\n * Empty settings return `input.color`. `highlighted`: the trees the Highlight marks (mutable, read every frame).\n */\nexport function applyTreeEffects(input: TreeEffectInput, settings: TreeEffectsSettings, highlighted: readonly (Tree | ForestTree)[] = []): Node<'vec4'> {\n return liveTreeEffects(input, settings, highlighted).node;\n}\n\n/**\n * The shape of a combination: what its graph is built from (the effects that are on, the glow\n * radius, the outline's `betweenTrees` and the normal encoding of Inner Lines). Settings of the same\n * shape only differ in uniforms.\n */\nfunction shapeOf(settings: TreeEffectsSettings, input: TreeEffectInput): string {\n const outline = settings.outline ? (drawsBetweenTrees(settings) ? 'between' : 'outline') : null;\n const innerLines = settings.innerLines ? (input.normalEncoding ?? 'color') : null;\n return JSON.stringify([!!settings.grade, settings.glow ? glowRadius(settings.glow) : null, outline, innerLines, !!settings.highlight]);\n}\n\n/** Whether the outline is also drawn between trees: part of the shape, and it needs the Tree ID channel. */\nfunction drawsBetweenTrees(settings: TreeEffectsSettings): boolean {\n return settings.outline?.betweenTrees === true;\n}\n\n/** {@link applyTreeEffects} with every colour and number as a uniform; `update()` needs the same shape. */\nfunction liveTreeEffects(\n input: TreeEffectInput,\n settings: TreeEffectsSettings,\n highlighted: readonly (Tree | ForestTree)[],\n): LiveTreeEffect<TreeEffectsSettings> {\n const updates: ((settings: TreeEffectsSettings) => void)[] = [];\n let color = input.color;\n if (settings.grade) {\n const grade = liveTreeColorGrade({ color, mask: input.mask }, settings.grade);\n updates.push((s) => grade.update(s.grade!));\n color = grade.node;\n }\n if (settings.glow) {\n const glow = liveLeafGlow({ color, mask: input.mask }, settings.glow);\n updates.push((s) => glow.update(s.glow!));\n color = glow.node;\n }\n if (settings.innerLines) {\n const lines = liveInnerLines({ ...input, color }, settings.innerLines);\n updates.push((s) => lines.update(s.innerLines!));\n color = lines.node;\n }\n if (settings.outline) {\n const outline = liveTreeOutline({ ...input, color }, settings.outline);\n updates.push((s) => outline.update(s.outline!));\n color = outline.node;\n }\n // Highlight last, so it always sits on top.\n if (settings.highlight) {\n const highlight = liveTreeHighlight({ ...input, color }, highlighted, settings.highlight);\n updates.push((s) => highlight.update(s.highlight!));\n color = highlight.node;\n }\n return { node: color, update: (s) => updates.forEach((update) => update(s)) };\n}\n\n/** The suggested combination of a built-in Style, or the settings themselves; `null` = no effects. */\nexport type TreeEffectsChoice = StyleName | TreeEffectsSettings | null;\n\nfunction resolveEffects(choice: TreeEffectsChoice): TreeEffectsSettings {\n if (choice === null) return {};\n if (typeof choice !== 'string') return choice;\n const settings = (SUGGESTED_TREE_EFFECTS as Record<string, TreeEffectsSettings | undefined>)[choice];\n if (!settings) throw new Error(`No suggested Tree Effects for Style \"${choice}\"`);\n return settings;\n}\n\nexport interface TreeEffectsOptions {\n /** Which effects: a Style name (its suggested combination), custom settings, or `null` (none). Default: none. */\n effects?: TreeEffectsChoice;\n /**\n * The trees to outline (Trees, Forests, groups of them; mutable, read on every draw).\n * Default: every tree in the scene.\n */\n selection?: Object3D[];\n /**\n * Keeps the Tree ID channel on even when no effect needs it, for {@link TreeEffects.pick}.\n * Default: false (the channel is only rendered when an effect needs it). Whenever the Tree ID\n * channel is on (this option, `outline.betweenTrees`, `highlight`, or the low-poly suggestion),\n * the scene pass renders without MSAA: an integer target cannot be multisampled.\n */\n treeId?: boolean;\n /**\n * The trees the Highlight marks (`effects: { highlight: {...} }`): Trees and Forest trees, at most\n * 64; mutable, read every frame, so hover and selection changes never recompile. Default: none\n * (a new empty list, see {@link TreeEffects.highlighted}).\n */\n highlighted?: (Tree | ForestTree)[];\n}\n\n/**\n * The extra channels the scene pass needs for `settings` (with the `treeId` option). Only this\n * set decides the scene pass's MRT: settings that need the same channels keep it.\n */\nfunction channelsFor(settings: TreeEffectsSettings, options: TreeEffectsOptions): TreeEffectsChannels {\n return {\n treeId: options.treeId === true || drawsBetweenTrees(settings) || !!settings.highlight,\n normal: !!settings.innerLines,\n };\n}\n\n/** A key that is equal for equal sets of channels. */\nfunction channelsKey(channels: TreeEffectsChannels): string {\n return Object.entries(channels)\n .filter(([, on]) => on === true)\n .map(([name]) => name)\n .sort()\n .join();\n}\n\n/**\n * A ready-made post-processing pipeline (`RenderPipeline`) with the Tree Effects: render with\n * `effects.render()` instead of `renderer.render(scene, camera)`. Switch the combination with\n * `effects.set('stylized')` (e.g. a preview). For your own pipeline, use {@link treeEffectsPass}\n * and {@link applyTreeEffects} instead.\n */\nexport class TreeEffects {\n readonly pipeline: RenderPipeline;\n /** The trees the Highlight marks (the `highlighted` option, or an empty list): change it in place. */\n readonly highlighted: (Tree | ForestTree)[];\n private nodes: Node[] = [];\n private current: TreeEffectsSettings = {};\n private graph: { shape: string; effects: LiveTreeEffect<TreeEffectsSettings> } | null = null;\n private input!: { channels: string; pass: TreeEffectsPass };\n\n constructor(\n private readonly renderer: Renderer,\n private readonly scene: Scene,\n private readonly camera: Camera,\n private readonly options: TreeEffectsOptions = {},\n ) {\n this.pipeline = new RenderPipeline(renderer);\n this.highlighted = options.highlighted ?? [];\n this.set(options.effects ?? null);\n }\n\n /**\n * The scene pass (colour + tree mask, plus the channels the settings need, such as the Tree ID).\n *\n * It is replaced by a new one (a new object, the old one disposed) when {@link set} needs another\n * set of channels, and only then; read it again after such a `set()` rather than keeping it.\n * Swapping only the MRT of one PassNode is not feasible with three: a PassNode can add targets\n * (`getTexture`) but has no way to remove one, and its sample count is fixed per target, so\n * turning a channel off (or the Tree ID off, which brings MSAA back) needs a new pass. Either way\n * the scene's materials recompile, because the MRT changes; settings that need the same channels\n * keep this pass and its MRT.\n */\n get scenePass(): TreeEffectsPass {\n return this.input.pass;\n }\n\n /** The active combination (`{}` = none). */\n get settings(): TreeEffectsSettings {\n return this.current;\n }\n\n /**\n * Switches to a Style's suggested combination, custom settings, or none (`null`). With the same\n * effects on (and the same glow radius) only the colours and numbers change, without a recompile;\n * otherwise a new graph is built and the old one freed.\n */\n set(effects: TreeEffectsChoice): void {\n this.current = resolveEffects(effects);\n const channels = channelsFor(this.current, this.options);\n const key = channelsKey(channels);\n if (this.input?.channels !== key) {\n // Other channels: a new scene pass (new MRT), and a new graph that reads it.\n this.disposeNodes();\n this.input?.pass.pass.dispose();\n this.input = { channels: key, pass: treeEffectsPass(this.scene, this.camera, this.options.selection ?? null, channels) };\n this.graph = null;\n }\n const shape = shapeOf(this.current, this.scenePass);\n if (this.graph?.shape === shape) {\n this.graph.effects.update(this.current);\n return;\n }\n this.disposeNodes();\n const live = liveTreeEffects(this.scenePass, this.current, this.highlighted);\n this.graph = { shape, effects: live };\n this.nodes = collectEffectNodes(live.node, this.scenePass.color);\n this.pipeline.outputNode = live.node;\n this.pipeline.needsUpdate = true;\n }\n\n /**\n * GPU picking: the Tree or Forest tree under a point of the canvas (CSS pixels from its top left\n * corner, as `event.offsetX/offsetY`) in the last render, or `undefined` where no tree is drawn.\n * Needs the Tree ID channel: throws when it is off (create the effects with `treeId: true`).\n */\n pick(x: number, y: number): Promise<Tree | ForestTree | undefined> {\n const { pass, treeId } = this.scenePass;\n if (!treeId) throw new Error('TreeEffects.pick() needs the Tree ID channel: create the effects with the `treeId: true` option');\n return readTreeId(this.renderer, pass, x, y).then(treeFromId);\n }\n\n /** Renders the scene with the effects (call instead of `renderer.render(scene, camera)`). */\n render(): void {\n this.pipeline.render();\n }\n\n dispose(): void {\n this.disposeNodes();\n this.scenePass.pass.dispose();\n this.pipeline.dispose();\n }\n\n private disposeNodes(): void {\n for (const node of this.nodes) node.dispose();\n this.nodes = [];\n }\n}\n\n/** The render-target owning nodes (blur) in an effects graph, to dispose them on change. */\nfunction collectEffectNodes(output: Node, stop: Node): Node[] {\n const found = new Set<Node>();\n const visit = (node: Node, seen: Set<Node>): void => {\n if (seen.has(node) || node === stop) return;\n seen.add(node);\n const n = node as Node & { isGaussianBlurNode?: boolean };\n if (n.isGaussianBlurNode) found.add(node);\n for (const child of node.getChildren()) visit(child as Node, seen);\n };\n visit(output, new Set());\n return [...found];\n}\n\n/** Shorthand for `new TreeEffects(renderer, scene, camera, options)`. */\nexport function createTreeEffects(renderer: Renderer, scene: Scene, camera: Camera, options?: TreeEffectsOptions): TreeEffects {\n return new TreeEffects(renderer, scene, camera, options);\n}\n"],"mappings":";;;;;AAIA,IAAa,YAAY;;;;;AASzB,SAAgB,WAAW,UAAwD;CACjF,MAAM,OAAgB,UAAU,SAAS;CACzC,OAAO,SAAS,UAAU,SAAS,YAAY,SAAS,UAAU,OAAO;AAC3E;AAEA,SAAS,WAAW,QAAyB,WAAyC;CACpF,KAAK,IAAI,IAAI,QAAQ,GAAG,IAAI,EAAE,QAAQ,IAAI,UAAU,SAAS,CAAC,GAAG,OAAO;CACxE,OAAO;AACT;;;;;;;;;;AAWA,SAAgB,eAAe,YAAwC,MAAoB;CACzF,OAAO,QAAQ,IAAI,QAAQ,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,gBAAgB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