@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.
Files changed (135) hide show
  1. package/README.md +590 -4
  2. package/dist/effects/custom.d.ts +62 -0
  3. package/dist/effects/custom.d.ts.map +1 -0
  4. package/dist/effects/effects.d.ts +42 -1
  5. package/dist/effects/effects.d.ts.map +1 -1
  6. package/dist/effects/index.d.ts +2 -0
  7. package/dist/effects/index.d.ts.map +1 -1
  8. package/dist/effects/mask.d.ts +9 -1
  9. package/dist/effects/mask.d.ts.map +1 -1
  10. package/dist/effects/tree-id.d.ts.map +1 -1
  11. package/dist/effects-qHx_8Dlk.js +1052 -0
  12. package/dist/effects-qHx_8Dlk.js.map +1 -0
  13. package/dist/effects.js +2 -963
  14. package/dist/forest/Forest.d.ts +80 -4
  15. package/dist/forest/Forest.d.ts.map +1 -1
  16. package/dist/forest/forest-lod.d.ts +70 -0
  17. package/dist/forest/forest-lod.d.ts.map +1 -0
  18. package/dist/forest/impostor-material.d.ts +106 -0
  19. package/dist/forest/impostor-material.d.ts.map +1 -0
  20. package/dist/forest/impostor-season.d.ts +13 -0
  21. package/dist/forest/impostor-season.d.ts.map +1 -0
  22. package/dist/forest/impostor.d.ts +105 -0
  23. package/dist/forest/impostor.d.ts.map +1 -0
  24. package/dist/forest/index.d.ts +1 -0
  25. package/dist/forest/index.d.ts.map +1 -1
  26. package/dist/forest/levels.d.ts +144 -0
  27. package/dist/forest/levels.d.ts.map +1 -0
  28. package/dist/forest/lod.d.ts +106 -0
  29. package/dist/forest/lod.d.ts.map +1 -0
  30. package/dist/forest/nodes.d.ts +42 -1
  31. package/dist/forest/nodes.d.ts.map +1 -1
  32. package/dist/forest/octahedral.d.ts +33 -0
  33. package/dist/forest/octahedral.d.ts.map +1 -0
  34. package/dist/{forest-lg61rhKM.js → forest-CM5DrklM.js} +1723 -340
  35. package/dist/forest-CM5DrklM.js.map +1 -0
  36. package/dist/generator/fruit.d.ts +2 -0
  37. package/dist/generator/fruit.d.ts.map +1 -1
  38. package/dist/generator/index.d.ts +1 -0
  39. package/dist/generator/index.d.ts.map +1 -1
  40. package/dist/generator/light.d.ts +36 -0
  41. package/dist/generator/light.d.ts.map +1 -0
  42. package/dist/index.d.ts +3 -2
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +5 -2
  45. package/dist/index.js.map +1 -1
  46. package/dist/materials/crown-nodes.d.ts +5 -0
  47. package/dist/materials/crown-nodes.d.ts.map +1 -1
  48. package/dist/materials/leaf-translucency-model.d.ts +6 -1
  49. package/dist/materials/leaf-translucency-model.d.ts.map +1 -1
  50. package/dist/materials/material-features.d.ts +12 -0
  51. package/dist/materials/material-features.d.ts.map +1 -1
  52. package/dist/materials/shader-hooks.d.ts +155 -0
  53. package/dist/materials/shader-hooks.d.ts.map +1 -0
  54. package/dist/motion-Qd7xjeZM.js +276 -0
  55. package/dist/motion-Qd7xjeZM.js.map +1 -0
  56. package/dist/nodes-DxgTyF9B.js +436 -0
  57. package/dist/nodes-DxgTyF9B.js.map +1 -0
  58. package/dist/react/Forest.d.ts +17 -3
  59. package/dist/react/Forest.d.ts.map +1 -1
  60. package/dist/react/ScenePipeline.d.ts +63 -0
  61. package/dist/react/ScenePipeline.d.ts.map +1 -0
  62. package/dist/react/SceneShaderHooks.d.ts +25 -0
  63. package/dist/react/SceneShaderHooks.d.ts.map +1 -0
  64. package/dist/react/Tree.d.ts +9 -2
  65. package/dist/react/Tree.d.ts.map +1 -1
  66. package/dist/react/Weather.d.ts +45 -0
  67. package/dist/react/Weather.d.ts.map +1 -0
  68. package/dist/react/Wind.d.ts +12 -1
  69. package/dist/react/Wind.d.ts.map +1 -1
  70. package/dist/react/index.d.ts +7 -1
  71. package/dist/react/index.d.ts.map +1 -1
  72. package/dist/react.js +347 -10
  73. package/dist/react.js.map +1 -1
  74. package/dist/renderer/index.d.ts +6 -0
  75. package/dist/renderer/index.d.ts.map +1 -1
  76. package/dist/scene/antialias.d.ts +35 -0
  77. package/dist/scene/antialias.d.ts.map +1 -0
  78. package/dist/scene/ao.d.ts +46 -0
  79. package/dist/scene/ao.d.ts.map +1 -0
  80. package/dist/scene/bloom.d.ts +19 -0
  81. package/dist/scene/bloom.d.ts.map +1 -0
  82. package/dist/scene/fog.d.ts +49 -0
  83. package/dist/scene/fog.d.ts.map +1 -0
  84. package/dist/scene/godrays.d.ts +37 -0
  85. package/dist/scene/godrays.d.ts.map +1 -0
  86. package/dist/scene/index.d.ts +14 -0
  87. package/dist/scene/index.d.ts.map +1 -0
  88. package/dist/scene/motion-blur.d.ts +23 -0
  89. package/dist/scene/motion-blur.d.ts.map +1 -0
  90. package/dist/scene/pipeline.d.ts +109 -0
  91. package/dist/scene/pipeline.d.ts.map +1 -0
  92. package/dist/scene/settings.d.ts +36 -0
  93. package/dist/scene/settings.d.ts.map +1 -0
  94. package/dist/scene/stack.d.ts +25 -0
  95. package/dist/scene/stack.d.ts.map +1 -0
  96. package/dist/scene/stage.d.ts +52 -0
  97. package/dist/scene/stage.d.ts.map +1 -0
  98. package/dist/scene/suggested.d.ts +12 -0
  99. package/dist/scene/suggested.d.ts.map +1 -0
  100. package/dist/scene/tone-mapping.d.ts +20 -0
  101. package/dist/scene/tone-mapping.d.ts.map +1 -0
  102. package/dist/scene/velocity.d.ts +34 -0
  103. package/dist/scene/velocity.d.ts.map +1 -0
  104. package/dist/scene.js +889 -0
  105. package/dist/scene.js.map +1 -0
  106. package/dist/season/nodes.d.ts +13 -0
  107. package/dist/season/nodes.d.ts.map +1 -1
  108. package/dist/shader-hooks-BFRtlWGI.js +275 -0
  109. package/dist/shader-hooks-BFRtlWGI.js.map +1 -0
  110. package/dist/tree/Tree.d.ts +8 -3
  111. package/dist/tree/Tree.d.ts.map +1 -1
  112. package/dist/tree/index.d.ts.map +1 -1
  113. package/dist/weather/index.d.ts +3 -0
  114. package/dist/weather/index.d.ts.map +1 -0
  115. package/dist/weather/shared.d.ts +43 -0
  116. package/dist/weather/shared.d.ts.map +1 -0
  117. package/dist/weather/snow.d.ts +87 -0
  118. package/dist/weather/snow.d.ts.map +1 -0
  119. package/dist/weather/wetness.d.ts +75 -0
  120. package/dist/weather/wetness.d.ts.map +1 -0
  121. package/dist/weather.js +288 -0
  122. package/dist/weather.js.map +1 -0
  123. package/dist/wind/Wind.d.ts +100 -5
  124. package/dist/wind/Wind.d.ts.map +1 -1
  125. package/dist/wind/burst.d.ts +28 -0
  126. package/dist/wind/burst.d.ts.map +1 -0
  127. package/dist/wind/index.d.ts +3 -2
  128. package/dist/wind/index.d.ts.map +1 -1
  129. package/dist/wind/motion.d.ts +30 -0
  130. package/dist/wind/motion.d.ts.map +1 -0
  131. package/dist/wind/node.d.ts +17 -3
  132. package/dist/wind/node.d.ts.map +1 -1
  133. package/package.json +9 -1
  134. package/dist/effects.js.map +0 -1
  135. package/dist/forest-lg61rhKM.js.map +0 -1
@@ -0,0 +1,276 @@
1
+ import { Vector3, Vector4 } from "three/webgpu";
2
+ import { Fn, float, mrt, uniform, uniformArray, vec4 } from "three/tsl";
3
+ // src/effects/mask.ts
4
+ /** Name of the tree mask output in a pass's MRT (`scenePass.getTextureNode(TREE_MASK)`). */
5
+ var TREE_MASK = "treeMask";
6
+ /** Every tree part, in their fixed order. */
7
+ var TREE_PARTS = [
8
+ "bark",
9
+ "leaves",
10
+ "fruit"
11
+ ];
12
+ /**
13
+ * Which tree part a material draws: 'bark', 'leaves' or 'fruit' for tree.js materials (and their clones),
14
+ * `null` for anything else. Tree Effects only change the pixels drawn by these materials.
15
+ */
16
+ function treePartOf(material) {
17
+ const part = material?.userData.treePart;
18
+ return part === "bark" || part === "leaves" || part === "fruit" ? part : null;
19
+ }
20
+ var leafMasks = /* @__PURE__ */ new WeakMap();
21
+ /**
22
+ * @internal For a material with `treePart` 'leaves' that also draws wood (an Impostor card): the
23
+ * fragment's leaf amount (0 wood .. 1 leaves), the tree mask's g there.
24
+ */
25
+ function setTreeLeafMask(material, leaf) {
26
+ leafMasks.set(material, leaf);
27
+ }
28
+ /** The leaf amount of the fragment drawn (see {@link setTreeLeafMask}), 1 for every other material. */
29
+ var leafMask = Fn((builder) => leafMasks.get(builder.material) ?? float(1));
30
+ function isSelected(object, selection) {
31
+ for (let o = object; o; o = o.parent) if (selection.includes(o)) return true;
32
+ return false;
33
+ }
34
+ /**
35
+ * TSL node: the tree mask value of the object being drawn, `vec4(tree, leaves, selected, 1)`:
36
+ * r = 1 on tree pixels (bark, leaves and Fruit), g = 1 on leaf pixels, b = 1 on pixels of selected trees (the outline's
37
+ * selection), 0 elsewhere. A per-object uniform decided from the drawn material
38
+ * ({@link treePartOf}), so no tree material is changed and every other object writes 0. An Impostor
39
+ * card (wood and leaves in one picture) writes g per fragment, from its baked leaf flag.
40
+ *
41
+ * `selection`: the selected tree objects (Trees, Forests, any ancestor of tree meshes), read on
42
+ * every draw, so it may be changed in place. `null` (default) selects every tree.
43
+ */
44
+ function createTreeMask(selection = null) {
45
+ const value = uniform(new Vector4(0, 0, 0, 1)).onObjectUpdate((frame, self) => {
46
+ const part = treePartOf(frame.material);
47
+ const selected = part !== null && (selection === null || isSelected(frame.object, selection));
48
+ self.value.set(part ? 1 : 0, part === "leaves" ? 1 : 0, selected ? 1 : 0, 1);
49
+ });
50
+ return vec4(value.x, value.y.mul(leafMask()), value.z, value.w);
51
+ }
52
+ /**
53
+ * The MRT output that renders the tree mask ({@link createTreeMask}) next to the colour. Merge it
54
+ * into the MRT of your own scene pass: `scenePass.setMRT(mrt({ output, normal: normalView }).merge(treeMaskMRT()))`,
55
+ * then read it with `scenePass.getTextureNode(TREE_MASK)`.
56
+ */
57
+ function treeMaskMRT(selection = null) {
58
+ const node = mrt({ [TREE_MASK]: createTreeMask(selection) });
59
+ node.setClearColor(TREE_MASK, 0, 0);
60
+ return node;
61
+ }
62
+ // src/wind/Wind.ts
63
+ /** Seconds a Wind Burst lasts. */
64
+ var WIND_BURST_LIFETIME = 1.2;
65
+ /** Most Wind Bursts one Wind runs at once; a new one beyond it replaces the oldest. */
66
+ var MAX_WIND_BURSTS = 8;
67
+ /** Metres a Wind Burst reaches per unit of strength, unless given a `radius`. */
68
+ var WIND_BURST_REACH = 8;
69
+ /**
70
+ * Whether a Wind (or a {@link WindBinding}) has ever had a Wind Burst. Tree materials only get burst
71
+ * nodes once it has: until then they are exactly as without Wind Bursts. Listeners are held weakly and
72
+ * told once.
73
+ */
74
+ var WindBurstsUsed = class {
75
+ used = false;
76
+ listeners = /* @__PURE__ */ new Set();
77
+ get triggered() {
78
+ return this.used;
79
+ }
80
+ /** Tells `listener` (at once if already triggered) when the first burst comes. */
81
+ listen(listener) {
82
+ if (this.used) {
83
+ listener.burstsUsed();
84
+ return;
85
+ }
86
+ if (this.listeners.size >= 256) {
87
+ for (const ref of this.listeners) if (!ref.deref()) this.listeners.delete(ref);
88
+ }
89
+ this.listeners.add(new WeakRef(listener));
90
+ }
91
+ /** Marks bursts as used and tells every listener (only the first time). */
92
+ trigger() {
93
+ if (this.used) return;
94
+ this.used = true;
95
+ const listeners = this.listeners;
96
+ this.listeners = /* @__PURE__ */ new Set();
97
+ for (const ref of listeners) ref.deref()?.burstsUsed();
98
+ }
99
+ };
100
+ /**
101
+ * Scene-wide Wind: a direction and a strength that every tree listening to it sways with.
102
+ * Changing them only writes uniform values (no recompile). Trees use {@link sceneWind} unless
103
+ * `createTree(..., { wind })` names another one. How much each tree moves is its Definition's
104
+ * Wind response (`definition.wind`).
105
+ */
106
+ var Wind = class {
107
+ /** The shared TSL uniforms tree materials read. Write through the setters, not here. */
108
+ uniforms;
109
+ pinnedTime = null;
110
+ /** The renderer clock as last seen by a render (the Wind time when not pinned). */
111
+ clock = 0;
112
+ /** Running and recently ended bursts, oldest first (at most {@link MAX_WIND_BURSTS}). */
113
+ started = [];
114
+ constructor(options = {}) {
115
+ this.uniforms = {
116
+ direction: uniform(new Vector3(1, 0, 0)),
117
+ strength: uniform(0),
118
+ time: uniform(0).onRenderUpdate((frame) => this.timeAt(frame.time)),
119
+ bursts: burstUniforms(() => this)
120
+ };
121
+ this.set(options);
122
+ }
123
+ /** Unit direction the wind blows towards (a copy: assign a new value to change it). */
124
+ get direction() {
125
+ return this.uniforms.direction.value.clone();
126
+ }
127
+ set direction(value) {
128
+ const v = Array.isArray(value) ? new Vector3(...value) : value.clone();
129
+ const length = v.length();
130
+ if (!Number.isFinite(length) || length === 0) throw new RangeError(`Wind direction must be a finite, non-zero vector, got [${v.toArray().join(", ")}]`);
131
+ this.uniforms.direction.value.copy(v.divideScalar(length));
132
+ }
133
+ get strength() {
134
+ return this.uniforms.strength.value;
135
+ }
136
+ set strength(value) {
137
+ if (!Number.isFinite(value) || value < 0) throw new RangeError(`Wind strength must be a finite number >= 0, got ${value}`);
138
+ this.uniforms.strength.value = value;
139
+ }
140
+ /**
141
+ * Pins the Wind clock to a time in seconds (pause, deterministic screenshots), or `null`
142
+ * (default) to follow the renderer's clock.
143
+ */
144
+ get time() {
145
+ return this.pinnedTime;
146
+ }
147
+ set time(value) {
148
+ this.pinnedTime = value;
149
+ if (value !== null) this.uniforms.time.value = value;
150
+ }
151
+ /**
152
+ * Starts a Wind Burst: a short push of air from a ground point that bends the trees within its
153
+ * radius away from it and fades out within {@link WIND_BURST_LIFETIME} seconds of Wind time, on top
154
+ * of the Wind. At most {@link MAX_WIND_BURSTS} run at once; another one replaces the oldest. Only
155
+ * uniform writes, except that the first burst on a Wind rebuilds the node graphs of the trees swaying
156
+ * with it once (never their geometry): until then their materials have no burst nodes at all. Returns this.
157
+ */
158
+ burst({ x, z, strength = 1, radius = 8 * Math.abs(strength) }) {
159
+ for (const [name, value] of Object.entries({
160
+ x,
161
+ z,
162
+ strength
163
+ })) if (!Number.isFinite(value)) throw new RangeError(`Wind burst ${name} must be a finite number, got ${value}`);
164
+ if (!(radius > 0 && Number.isFinite(radius))) throw new RangeError(`Wind burst radius must be > 0, got ${radius}`);
165
+ const running = this.bursts;
166
+ if (running.length === 8) running.shift();
167
+ this.started = [...running, {
168
+ x,
169
+ z,
170
+ strength,
171
+ radius,
172
+ start: this.now
173
+ }];
174
+ this.uniforms.bursts.used.trigger();
175
+ return this;
176
+ }
177
+ /**
178
+ * @internal The bursts the shader loops over (oldest first, at most {@link MAX_WIND_BURSTS}): the
179
+ * started ones while any of them runs, else none. They only change in {@link Wind.burst}; the
180
+ * shader leaves out those that have not started or have ended.
181
+ */
182
+ get drawnBursts() {
183
+ const last = this.started.at(-1);
184
+ return last && this.now - last.start <= 1.2 ? this.started : [];
185
+ }
186
+ /** The Wind Bursts running at the current Wind time, oldest first. */
187
+ get bursts() {
188
+ const now = this.now;
189
+ return this.started.filter((burst) => now >= burst.start && now - burst.start <= 1.2);
190
+ }
191
+ /**
192
+ * @internal The Wind time of a render at renderer time `frameTime` (called once per render by
193
+ * the Wind's own and its bindings' time uniforms): the pinned time, or that clock, which it keeps.
194
+ */
195
+ timeAt(frameTime) {
196
+ this.clock = frameTime;
197
+ return this.now;
198
+ }
199
+ /** The current Wind time: the pinned time, or the renderer clock as of the last render. */
200
+ get now() {
201
+ return this.pinnedTime ?? this.clock;
202
+ }
203
+ /** Sets direction and/or strength; returns this. */
204
+ set(options) {
205
+ if (options.direction !== void 0) this.direction = options.direction;
206
+ if (options.strength !== void 0) this.strength = options.strength;
207
+ return this;
208
+ }
209
+ };
210
+ /** The scene-wide Wind every tree sways with by default. */
211
+ var sceneWind = new Wind();
212
+ /**
213
+ * Per-object Wind uniforms that follow whichever Wind is bound to them, read once per render.
214
+ * Trees and Forests build their Wind nodes on these, so switching to another Wind is one
215
+ * assignment: no new nodes, no recompile, no regeneration (only the first time the binding follows a
216
+ * Wind that has had a Wind Burst do the materials built on it add burst nodes, one rebuild).
217
+ */
218
+ var WindBinding = class {
219
+ uniforms;
220
+ bound;
221
+ constructor(wind) {
222
+ this.bound = wind;
223
+ const direction = wind.uniforms.direction.value.clone();
224
+ this.uniforms = {
225
+ direction: uniform(direction).onRenderUpdate(() => direction.copy(this.wind.uniforms.direction.value)),
226
+ strength: uniform(wind.strength).onRenderUpdate(() => this.wind.strength),
227
+ time: uniform(0).onRenderUpdate((frame) => this.wind.timeAt(frame.time)),
228
+ bursts: burstUniforms(() => this.wind)
229
+ };
230
+ wind.uniforms.bursts.used.listen(this);
231
+ }
232
+ /** The bound Wind. Binding one that has had a Wind Burst switches bursts on (see {@link WindBurstsUsed}). */
233
+ get wind() {
234
+ return this.bound;
235
+ }
236
+ set wind(value) {
237
+ this.bound = value;
238
+ if (!this.uniforms.bursts.used.triggered) value.uniforms.bursts.used.listen(this);
239
+ }
240
+ /** @internal A Wind this binding listened to had its first burst: switch bursts on if it is still the bound one. */
241
+ burstsUsed() {
242
+ if (this.bound.uniforms.bursts.used.triggered) this.uniforms.bursts.used.trigger();
243
+ }
244
+ };
245
+ /** Burst uniforms that follow the bursts of `wind()`, read once per render. */
246
+ function burstUniforms(wind) {
247
+ const points = Array.from({ length: 8 }, () => new Vector4());
248
+ const radii = new Array(8).fill(1);
249
+ return {
250
+ points: uniformArray(points, "vec4").onRenderUpdate(() => {
251
+ wind().drawnBursts.forEach((b, i) => points[i].set(b.x, b.z, b.start, b.strength));
252
+ }),
253
+ radii: uniformArray(radii, "float").onRenderUpdate(() => {
254
+ wind().drawnBursts.forEach((b, i) => radii[i] = b.radius);
255
+ }),
256
+ count: uniform(0, "int").onRenderUpdate(() => wind().drawnBursts.length),
257
+ used: new WindBurstsUsed()
258
+ };
259
+ }
260
+ // src/wind/motion.ts
261
+ var motions = /* @__PURE__ */ new WeakMap();
262
+ /** Registers the Wind motion of the materials drawn with `positionNode`. */
263
+ function setWindMotion(positionNode, motion) {
264
+ motions.set(positionNode, motion);
265
+ }
266
+ /** The Wind motion of a material's `positionNode`, if it is a tree.js tree position. */
267
+ function windMotionOf(positionNode) {
268
+ return positionNode ? motions.get(positionNode) : void 0;
269
+ }
270
+ /** The Wind time (seconds) a source shows at renderer time `frameTime`: its pinned time, or the clock. */
271
+ function windTimeOf(source, frameTime) {
272
+ return (source instanceof WindBinding ? source.wind : source instanceof Wind ? source : null)?.time ?? frameTime;
273
+ }
274
+ export { WIND_BURST_LIFETIME as a, WindBinding as c, TREE_PARTS as d, createTreeMask as f, treePartOf as h, MAX_WIND_BURSTS as i, sceneWind as l, treeMaskMRT as m, windMotionOf as n, WIND_BURST_REACH as o, setTreeLeafMask as p, windTimeOf as r, Wind as s, setWindMotion as t, TREE_MASK as u };
275
+
276
+ //# sourceMappingURL=motion-Qd7xjeZM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"motion-Qd7xjeZM.js","names":[],"sources":["../src/effects/mask.ts","../src/wind/Wind.ts","../src/wind/motion.ts"],"sourcesContent":["import { Vector4, type Camera, type Material, type MRTNode, type Node, type NodeBuilder, type Object3D, type TextureNode } from 'three/webgpu';\nimport { float, Fn, mrt, uniform, vec4 } 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/** Every tree part, in their fixed order. */\nexport const TREE_PARTS: readonly 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\n// Materials that draw wood and leaves in one mesh (the Impostor cards) say per fragment which is which.\nconst leafMasks = new WeakMap<Material, Node<'float'>>();\n\n/**\n * @internal For a material with `treePart` 'leaves' that also draws wood (an Impostor card): the\n * fragment's leaf amount (0 wood .. 1 leaves), the tree mask's g there.\n */\nexport function setTreeLeafMask(material: Material, leaf: Node<'float'>): void {\n leafMasks.set(material, leaf);\n}\n\n/** The leaf amount of the fragment drawn (see {@link setTreeLeafMask}), 1 for every other material. */\nconst leafMask = Fn((builder: NodeBuilder) => leafMasks.get(builder.material as Material) ?? float(1)) as unknown as () => Node<'float'>;\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. An Impostor\n * card (wood and leaves in one picture) writes g per fragment, from its baked leaf flag.\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 const value = 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 return vec4(value.x, value.y.mul(leafMask()), value.z, value.w);\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 { Vector3, Vector4, type UniformArrayNode, type UniformNode } from 'three/webgpu';\nimport { uniform, uniformArray } from 'three/tsl';\n\nexport type WindDirection = Vector3 | readonly [number, number, number];\n\nexport interface WindOptions {\n /** World-space direction the wind blows towards (any length > 0; stored as a unit vector). Default +X. */\n direction?: WindDirection;\n /** 0 = calm (default), 1 = strong wind; larger values are allowed for storms. */\n strength?: number;\n}\n\n/** A {@link Wind.burst}: where on the ground, how hard and how far. */\nexport interface WindBurstOptions {\n /** World-space ground point (x, z) the air pushes away from. */\n x: number;\n z: number;\n /**\n * How hard it pushes (default 1). Weaker values push less; a negative value is the reduced-motion\n * burst: trees in reach lean away at once (no travelling front, no swing back) and settle, with\n * the size of the value as strength.\n */\n strength?: number;\n /** Metres it reaches (> 0). Default {@link WIND_BURST_REACH} per unit of strength. */\n radius?: number;\n}\n\n/** A running Wind Burst, as {@link Wind.bursts} lists it. */\nexport interface WindBurst {\n readonly x: number;\n readonly z: number;\n readonly strength: number;\n readonly radius: number;\n /** The Wind time (seconds) it started at. */\n readonly start: number;\n}\n\n/** Seconds a Wind Burst lasts. */\nexport const WIND_BURST_LIFETIME = 1.2;\n/** Most Wind Bursts one Wind runs at once; a new one beyond it replaces the oldest. */\nexport const MAX_WIND_BURSTS = 8;\n/** Metres a Wind Burst reaches per unit of strength, unless given a `radius`. */\nexport const WIND_BURST_REACH = 8;\n\n/** Something that switches Wind Bursts on once they are used (see {@link WindBurstsUsed}). */\nexport interface BurstListener {\n burstsUsed(): void;\n}\n\n/**\n * Whether a Wind (or a {@link WindBinding}) has ever had a Wind Burst. Tree materials only get burst\n * nodes once it has: until then they are exactly as without Wind Bursts. Listeners are held weakly and\n * told once.\n */\nexport class WindBurstsUsed {\n private used = false;\n private listeners = new Set<WeakRef<BurstListener>>();\n\n get triggered(): boolean {\n return this.used;\n }\n\n /** Tells `listener` (at once if already triggered) when the first burst comes. */\n listen(listener: BurstListener): void {\n if (this.used) {\n listener.burstsUsed();\n return;\n }\n if (this.listeners.size >= 256) for (const ref of this.listeners) if (!ref.deref()) this.listeners.delete(ref);\n this.listeners.add(new WeakRef(listener));\n }\n\n /** Marks bursts as used and tells every listener (only the first time). */\n trigger(): void {\n if (this.used) return;\n this.used = true;\n const listeners = this.listeners;\n this.listeners = new Set();\n for (const ref of listeners) ref.deref()?.burstsUsed();\n }\n}\n\n/**\n * Scene-wide Wind: a direction and a strength that every tree listening to it sways with.\n * Changing them only writes uniform values (no recompile). Trees use {@link sceneWind} unless\n * `createTree(..., { wind })` names another one. How much each tree moves is its Definition's\n * Wind response (`definition.wind`).\n */\nexport class Wind {\n /** The shared TSL uniforms tree materials read. Write through the setters, not here. */\n readonly uniforms: {\n readonly direction: UniformNode<'vec3', Vector3>;\n readonly strength: UniformNode<'float', number>;\n /** Seconds; follows the renderer clock unless {@link Wind.time} pins it. */\n readonly time: UniformNode<'float', number>;\n /** Wind Bursts (see {@link WindBurstUniforms}). */\n readonly bursts: WindBurstUniforms;\n };\n private pinnedTime: number | null = null;\n /** The renderer clock as last seen by a render (the Wind time when not pinned). */\n private clock = 0;\n /** Running and recently ended bursts, oldest first (at most {@link MAX_WIND_BURSTS}). */\n private started: WindBurst[] = [];\n\n constructor(options: WindOptions = {}) {\n this.uniforms = {\n direction: uniform(new Vector3(1, 0, 0)),\n strength: uniform(0),\n time: uniform(0).onRenderUpdate((frame) => this.timeAt(frame.time)),\n bursts: burstUniforms(() => this),\n };\n this.set(options);\n }\n\n /** Unit direction the wind blows towards (a copy: assign a new value to change it). */\n get direction(): Vector3 {\n return this.uniforms.direction.value.clone();\n }\n\n set direction(value: WindDirection) {\n const v = Array.isArray(value) ? new Vector3(...(value as [number, number, number])) : (value as Vector3).clone();\n const length = v.length();\n if (!Number.isFinite(length) || length === 0) {\n throw new RangeError(`Wind direction must be a finite, non-zero vector, got [${v.toArray().join(', ')}]`);\n }\n this.uniforms.direction.value.copy(v.divideScalar(length));\n }\n\n get strength(): number {\n return this.uniforms.strength.value;\n }\n\n set strength(value: number) {\n if (!Number.isFinite(value) || value < 0) throw new RangeError(`Wind strength must be a finite number >= 0, got ${value}`);\n this.uniforms.strength.value = value;\n }\n\n /**\n * Pins the Wind clock to a time in seconds (pause, deterministic screenshots), or `null`\n * (default) to follow the renderer's clock.\n */\n get time(): number | null {\n return this.pinnedTime;\n }\n\n set time(value: number | null) {\n this.pinnedTime = value;\n if (value !== null) this.uniforms.time.value = value;\n }\n\n /**\n * Starts a Wind Burst: a short push of air from a ground point that bends the trees within its\n * radius away from it and fades out within {@link WIND_BURST_LIFETIME} seconds of Wind time, on top\n * of the Wind. At most {@link MAX_WIND_BURSTS} run at once; another one replaces the oldest. Only\n * uniform writes, except that the first burst on a Wind rebuilds the node graphs of the trees swaying\n * with it once (never their geometry): until then their materials have no burst nodes at all. Returns this.\n */\n burst({ x, z, strength = 1, radius = WIND_BURST_REACH * Math.abs(strength) }: WindBurstOptions): this {\n for (const [name, value] of Object.entries({ x, z, strength })) {\n if (!Number.isFinite(value)) throw new RangeError(`Wind burst ${name} must be a finite number, got ${value}`);\n }\n if (!(radius > 0 && Number.isFinite(radius))) throw new RangeError(`Wind burst radius must be > 0, got ${radius}`);\n const running = this.bursts;\n if (running.length === MAX_WIND_BURSTS) running.shift();\n this.started = [...running, { x, z, strength, radius, start: this.now }];\n this.uniforms.bursts.used.trigger();\n return this;\n }\n\n /**\n * @internal The bursts the shader loops over (oldest first, at most {@link MAX_WIND_BURSTS}): the\n * started ones while any of them runs, else none. They only change in {@link Wind.burst}; the\n * shader leaves out those that have not started or have ended.\n */\n get drawnBursts(): readonly WindBurst[] {\n const last = this.started.at(-1);\n return last && this.now - last.start <= WIND_BURST_LIFETIME ? this.started : [];\n }\n\n /** The Wind Bursts running at the current Wind time, oldest first. */\n get bursts(): WindBurst[] {\n const now = this.now;\n return this.started.filter((burst) => now >= burst.start && now - burst.start <= WIND_BURST_LIFETIME);\n }\n\n /**\n * @internal The Wind time of a render at renderer time `frameTime` (called once per render by\n * the Wind's own and its bindings' time uniforms): the pinned time, or that clock, which it keeps.\n */\n timeAt(frameTime: number): number {\n this.clock = frameTime;\n return this.now;\n }\n\n /** The current Wind time: the pinned time, or the renderer clock as of the last render. */\n private get now(): number {\n return this.pinnedTime ?? this.clock;\n }\n\n /** Sets direction and/or strength; returns this. */\n set(options: WindOptions): this {\n if (options.direction !== undefined) this.direction = options.direction;\n if (options.strength !== undefined) this.strength = options.strength;\n return this;\n }\n}\n\n/** The scene-wide Wind every tree sways with by default. */\nexport const sceneWind = new Wind();\n\n/** The uniforms Wind nodes read: those of a {@link Wind}, or of a {@link WindBinding}. */\nexport type WindUniforms = Wind['uniforms'];\n\n/**\n * Per-object Wind uniforms that follow whichever Wind is bound to them, read once per render.\n * Trees and Forests build their Wind nodes on these, so switching to another Wind is one\n * assignment: no new nodes, no recompile, no regeneration (only the first time the binding follows a\n * Wind that has had a Wind Burst do the materials built on it add burst nodes, one rebuild).\n */\nexport class WindBinding implements BurstListener {\n readonly uniforms: WindUniforms;\n private bound: Wind;\n\n constructor(wind: Wind) {\n this.bound = wind;\n const direction = wind.uniforms.direction.value.clone();\n this.uniforms = {\n direction: uniform(direction).onRenderUpdate(() => direction.copy(this.wind.uniforms.direction.value)),\n strength: uniform(wind.strength).onRenderUpdate(() => this.wind.strength),\n time: uniform(0).onRenderUpdate((frame) => this.wind.timeAt(frame.time)),\n bursts: burstUniforms(() => this.wind),\n };\n wind.uniforms.bursts.used.listen(this);\n }\n\n /** The bound Wind. Binding one that has had a Wind Burst switches bursts on (see {@link WindBurstsUsed}). */\n get wind(): Wind {\n return this.bound;\n }\n\n set wind(value: Wind) {\n this.bound = value;\n if (!this.uniforms.bursts.used.triggered) value.uniforms.bursts.used.listen(this);\n }\n\n /** @internal A Wind this binding listened to had its first burst: switch bursts on if it is still the bound one. */\n burstsUsed(): void {\n if (this.bound.uniforms.bursts.used.triggered) this.uniforms.bursts.used.trigger();\n }\n}\n\n\n/**\n * The Wind Burst uniforms tree materials read: a fixed-size array of {@link MAX_WIND_BURSTS} slots,\n * and how many of them to loop over (0 when no burst runs, so the loop costs nothing). Tree materials\n * only read them once a burst has been triggered (`used`).\n */\nexport interface WindBurstUniforms {\n /** Per slot: x, z (world-space ground point), start (Wind time), strength. */\n readonly points: UniformArrayNode<'vec4'>;\n /** Per slot: the radius in metres. */\n readonly radii: UniformArrayNode<'float'>;\n readonly count: UniformNode<'int', number>;\n /** Whether any burst has been triggered (then materials add burst nodes; see {@link WindBurstsUsed}). */\n readonly used: WindBurstsUsed;\n}\n\n/** Burst uniforms that follow the bursts of `wind()`, read once per render. */\nfunction burstUniforms(wind: () => Wind): WindBurstUniforms {\n const points = Array.from({ length: MAX_WIND_BURSTS }, () => new Vector4());\n const radii = new Array<number>(MAX_WIND_BURSTS).fill(1);\n return {\n points: uniformArray(points, 'vec4').onRenderUpdate(() => {\n wind().drawnBursts.forEach((b, i) => points[i]!.set(b.x, b.z, b.start, b.strength));\n }) as UniformArrayNode<'vec4'>,\n radii: uniformArray(radii, 'float').onRenderUpdate(() => {\n wind().drawnBursts.forEach((b, i) => (radii[i] = b.radius));\n }) as UniformArrayNode<'float'>,\n count: uniform(0, 'int').onRenderUpdate(() => wind().drawnBursts.length) as UniformNode<'int', number>,\n used: new WindBurstsUsed(),\n };\n}\n","import type { Node } from 'three/webgpu';\nimport { Wind, WindBinding } from './Wind';\nimport type { WindSource } from './node';\n\n/**\n * How a tree material's vertices move with the Wind between two Wind times, for Wind-aware velocity\n * (ADR 0011). Registered by Trees and Forests next to their materials' `positionNode`; read only by\n * a scene pass that asks for a velocity channel (`windVelocityMRT` in `@casmo/tree.js/scene`). The\n * materials themselves are never changed for it.\n */\nexport interface WindMotion {\n /** The Wind (or binding) the material sways with: its clock gives the current Wind time. */\n readonly source: WindSource;\n /**\n * TSL node: where each vertex was at Wind time `previous` relative to where it is now, in the\n * space `positionNode` outputs (the shader's `positionLocal`). Only Wind: Growth and Season are\n * the current ones (they are not motion).\n */\n shift(previous: Node<'float'>): Node<'vec3'>;\n /**\n * TSL node: the current Wind displacement of each vertex, in the space `positionNode` outputs (only\n * attributes and uniforms). Tree Shader Hooks turn the smooth normal with it (the swayed normal).\n */\n readonly offset?: Node<'vec3'>;\n}\n\n// Keyed by the material's positionNode, so material clones (which share it) move the same, and a\n// replaced positionNode (no longer ours) falls back to three's own velocity. Limitation: an app that\n// replaces a tree material's positionNode (even with one that wraps ours) drops its Wind velocity:\n// TRAA may then ghost and motion blur miss the sway of those trees.\nconst motions = new WeakMap<Node, WindMotion>();\n\n/** Registers the Wind motion of the materials drawn with `positionNode`. */\nexport function setWindMotion(positionNode: Node, motion: WindMotion): void {\n motions.set(positionNode, motion);\n}\n\n/** The Wind motion of a material's `positionNode`, if it is a tree.js tree position. */\nexport function windMotionOf(positionNode: Node | null | undefined): WindMotion | undefined {\n return positionNode ? motions.get(positionNode) : undefined;\n}\n\n/** The Wind time (seconds) a source shows at renderer time `frameTime`: its pinned time, or the clock. */\nexport function windTimeOf(source: WindSource, frameTime: number): number {\n const wind = source instanceof WindBinding ? source.wind : source instanceof Wind ? source : null;\n return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