@casmo/tree.js 0.0.0-stage → 0.1.1

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 (153) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +485 -2
  3. package/dist/bake/index.d.ts +39 -0
  4. package/dist/bake/index.d.ts.map +1 -0
  5. package/dist/definition/defaults.d.ts +9 -0
  6. package/dist/definition/defaults.d.ts.map +1 -0
  7. package/dist/definition/index.d.ts +5 -0
  8. package/dist/definition/index.d.ts.map +1 -0
  9. package/dist/definition/migrations.d.ts +12 -0
  10. package/dist/definition/migrations.d.ts.map +1 -0
  11. package/dist/definition/parse.d.ts +30 -0
  12. package/dist/definition/parse.d.ts.map +1 -0
  13. package/dist/definition/schema.d.ts +13 -0
  14. package/dist/definition/schema.d.ts.map +1 -0
  15. package/dist/definition/types.d.ts +217 -0
  16. package/dist/definition/types.d.ts.map +1 -0
  17. package/dist/effects/effects.d.ts +46 -0
  18. package/dist/effects/effects.d.ts.map +1 -0
  19. package/dist/effects/glow.d.ts +19 -0
  20. package/dist/effects/glow.d.ts.map +1 -0
  21. package/dist/effects/grade.d.ts +19 -0
  22. package/dist/effects/grade.d.ts.map +1 -0
  23. package/dist/effects/index.d.ts +7 -0
  24. package/dist/effects/index.d.ts.map +1 -0
  25. package/dist/effects/mask.d.ts +44 -0
  26. package/dist/effects/mask.d.ts.map +1 -0
  27. package/dist/effects/outline.d.ts +18 -0
  28. package/dist/effects/outline.d.ts.map +1 -0
  29. package/dist/effects/suggested.d.ts +13 -0
  30. package/dist/effects/suggested.d.ts.map +1 -0
  31. package/dist/effects.js +249 -0
  32. package/dist/effects.js.map +1 -0
  33. package/dist/forest/Forest.d.ts +156 -0
  34. package/dist/forest/Forest.d.ts.map +1 -0
  35. package/dist/forest/index.d.ts +14 -0
  36. package/dist/forest/index.d.ts.map +1 -0
  37. package/dist/forest/nodes.d.ts +31 -0
  38. package/dist/forest/nodes.d.ts.map +1 -0
  39. package/dist/forest/placement.d.ts +52 -0
  40. package/dist/forest/placement.d.ts.map +1 -0
  41. package/dist/forest-OX9WvAwh.js +3057 -0
  42. package/dist/forest-OX9WvAwh.js.map +1 -0
  43. package/dist/generator/attributes.d.ts +20 -0
  44. package/dist/generator/attributes.d.ts.map +1 -0
  45. package/dist/generator/branches.d.ts +12 -0
  46. package/dist/generator/branches.d.ts.map +1 -0
  47. package/dist/generator/frames.d.ts +21 -0
  48. package/dist/generator/frames.d.ts.map +1 -0
  49. package/dist/generator/growth.d.ts +15 -0
  50. package/dist/generator/growth.d.ts.map +1 -0
  51. package/dist/generator/index.d.ts +22 -0
  52. package/dist/generator/index.d.ts.map +1 -0
  53. package/dist/generator/leaf-shapes.d.ts +10 -0
  54. package/dist/generator/leaf-shapes.d.ts.map +1 -0
  55. package/dist/generator/leaves.d.ts +14 -0
  56. package/dist/generator/leaves.d.ts.map +1 -0
  57. package/dist/generator/mesh.d.ts +11 -0
  58. package/dist/generator/mesh.d.ts.map +1 -0
  59. package/dist/generator/sculpt.d.ts +28 -0
  60. package/dist/generator/sculpt.d.ts.map +1 -0
  61. package/dist/generator/trunk.d.ts +6 -0
  62. package/dist/generator/trunk.d.ts.map +1 -0
  63. package/dist/generator/types.d.ts +126 -0
  64. package/dist/generator/types.d.ts.map +1 -0
  65. package/dist/generator/vec.d.ts +12 -0
  66. package/dist/generator/vec.d.ts.map +1 -0
  67. package/dist/generator/wind.d.ts +27 -0
  68. package/dist/generator/wind.d.ts.map +1 -0
  69. package/dist/growth/evaluate.d.ts +32 -0
  70. package/dist/growth/evaluate.d.ts.map +1 -0
  71. package/dist/growth/index.d.ts +3 -0
  72. package/dist/growth/index.d.ts.map +1 -0
  73. package/dist/growth/tsl.d.ts +12 -0
  74. package/dist/growth/tsl.d.ts.map +1 -0
  75. package/dist/index.d.ts +14 -0
  76. package/dist/index.d.ts.map +1 -0
  77. package/dist/index.js +198 -0
  78. package/dist/index.js.map +1 -0
  79. package/dist/materials/index.d.ts +18 -0
  80. package/dist/materials/index.d.ts.map +1 -0
  81. package/dist/materials/maps.d.ts +23 -0
  82. package/dist/materials/maps.d.ts.map +1 -0
  83. package/dist/materials/shading.d.ts +18 -0
  84. package/dist/materials/shading.d.ts.map +1 -0
  85. package/dist/materials/toon.d.ts +12 -0
  86. package/dist/materials/toon.d.ts.map +1 -0
  87. package/dist/math/index.d.ts +23 -0
  88. package/dist/math/index.d.ts.map +1 -0
  89. package/dist/profiles-BAiyeFlh.js +113 -0
  90. package/dist/profiles-BAiyeFlh.js.map +1 -0
  91. package/dist/random/index.d.ts +37 -0
  92. package/dist/random/index.d.ts.map +1 -0
  93. package/dist/react/Forest.d.ts +54 -0
  94. package/dist/react/Forest.d.ts.map +1 -0
  95. package/dist/react/Tree.d.ts +41 -0
  96. package/dist/react/Tree.d.ts.map +1 -0
  97. package/dist/react/Wind.d.ts +17 -0
  98. package/dist/react/Wind.d.ts.map +1 -0
  99. package/dist/react/index.d.ts +6 -0
  100. package/dist/react/index.d.ts.map +1 -0
  101. package/dist/react/useTreeStyle.d.ts +15 -0
  102. package/dist/react/useTreeStyle.d.ts.map +1 -0
  103. package/dist/react.js +239 -0
  104. package/dist/react.js.map +1 -0
  105. package/dist/renderer/index.d.ts +7 -0
  106. package/dist/renderer/index.d.ts.map +1 -0
  107. package/dist/season/check.d.ts +3 -0
  108. package/dist/season/check.d.ts.map +1 -0
  109. package/dist/season/index.d.ts +4 -0
  110. package/dist/season/index.d.ts.map +1 -0
  111. package/dist/season/nodes.d.ts +32 -0
  112. package/dist/season/nodes.d.ts.map +1 -0
  113. package/dist/season/profile.d.ts +78 -0
  114. package/dist/season/profile.d.ts.map +1 -0
  115. package/dist/season/profiles.d.ts +40 -0
  116. package/dist/season/profiles.d.ts.map +1 -0
  117. package/dist/styles/low-poly/index.d.ts +16 -0
  118. package/dist/styles/low-poly/index.d.ts.map +1 -0
  119. package/dist/styles/low-poly.js +165 -0
  120. package/dist/styles/low-poly.js.map +1 -0
  121. package/dist/styles/realistic/index.d.ts +23 -0
  122. package/dist/styles/realistic/index.d.ts.map +1 -0
  123. package/dist/styles/realistic.js +206 -0
  124. package/dist/styles/realistic.js.map +1 -0
  125. package/dist/styles/registry.d.ts +17 -0
  126. package/dist/styles/registry.d.ts.map +1 -0
  127. package/dist/styles/stylized/index.d.ts +17 -0
  128. package/dist/styles/stylized/index.d.ts.map +1 -0
  129. package/dist/styles/stylized.js +266 -0
  130. package/dist/styles/stylized.js.map +1 -0
  131. package/dist/styles/types.d.ts +12 -0
  132. package/dist/styles/types.d.ts.map +1 -0
  133. package/dist/textures/index.d.ts +44 -0
  134. package/dist/textures/index.d.ts.map +1 -0
  135. package/dist/textures/realistic/bark-normal.png +0 -0
  136. package/dist/textures/realistic/bark.png +0 -0
  137. package/dist/textures/realistic/leaf.png +0 -0
  138. package/dist/textures/realistic/needles.png +0 -0
  139. package/dist/tree/Tree.d.ts +70 -0
  140. package/dist/tree/Tree.d.ts.map +1 -0
  141. package/dist/tree/index.d.ts +14 -0
  142. package/dist/tree/index.d.ts.map +1 -0
  143. package/dist/types-BZjHhNz7.js +20 -0
  144. package/dist/types-BZjHhNz7.js.map +1 -0
  145. package/dist/wind/Wind.d.ts +54 -0
  146. package/dist/wind/Wind.d.ts.map +1 -0
  147. package/dist/wind/index.d.ts +4 -0
  148. package/dist/wind/index.d.ts.map +1 -0
  149. package/dist/wind/node.d.ts +38 -0
  150. package/dist/wind/node.d.ts.map +1 -0
  151. package/dist/wind/response.d.ts +27 -0
  152. package/dist/wind/response.d.ts.map +1 -0
  153. package/package.json +107 -4
@@ -0,0 +1,249 @@
1
+ import { Color, RenderPipeline, UnsignedByteType, Vector4 } from "three/webgpu";
2
+ import { color, float, luminance, mix, mrt, output, pass, select, smoothstep, textureSize, uniform, uv, vec2, vec3, vec4 } from "three/tsl";
3
+ import { gaussianBlur } from "three/addons/tsl/display/GaussianBlurNode.js";
4
+ // src/effects/mask.ts
5
+ /** Name of the tree mask output in a pass's MRT (`scenePass.getTextureNode(TREE_MASK)`). */
6
+ var TREE_MASK = "treeMask";
7
+ /**
8
+ * Which tree part a material draws: 'bark' or 'leaves' for tree.js materials (and their clones),
9
+ * `null` for anything else. Tree Effects only change the pixels drawn by these materials.
10
+ */
11
+ function treePartOf(material) {
12
+ const part = material?.userData.treePart;
13
+ return part === "bark" || part === "leaves" ? part : null;
14
+ }
15
+ function isSelected(object, selection) {
16
+ for (let o = object; o; o = o.parent) if (selection.includes(o)) return true;
17
+ return false;
18
+ }
19
+ /**
20
+ * TSL node: the tree mask value of the object being drawn, `vec4(tree, leaves, selected, 1)`:
21
+ * r = 1 on tree pixels, g = 1 on leaf pixels, b = 1 on pixels of selected trees (the outline's
22
+ * selection), 0 elsewhere. A per-object uniform decided from the drawn material
23
+ * ({@link treePartOf}), so no tree material is changed and every other object writes 0.
24
+ *
25
+ * `selection`: the selected tree objects (Trees, Forests, any ancestor of tree meshes), read on
26
+ * every draw, so it may be changed in place. `null` (default) selects every tree.
27
+ */
28
+ function createTreeMask(selection = null) {
29
+ return uniform(new Vector4(0, 0, 0, 1)).onObjectUpdate((frame, self) => {
30
+ const part = treePartOf(frame.material);
31
+ const selected = part !== null && (selection === null || isSelected(frame.object, selection));
32
+ self.value.set(part ? 1 : 0, part === "leaves" ? 1 : 0, selected ? 1 : 0, 1);
33
+ });
34
+ }
35
+ /**
36
+ * The MRT output that renders the tree mask ({@link createTreeMask}) next to the colour. Merge it
37
+ * into the MRT of your own scene pass: `scenePass.setMRT(mrt({ output, normal: normalView }).merge(treeMaskMRT()))`,
38
+ * then read it with `scenePass.getTextureNode(TREE_MASK)`.
39
+ */
40
+ function treeMaskMRT(selection = null) {
41
+ const node = mrt({ [TREE_MASK]: createTreeMask(selection) });
42
+ node.setClearColor(TREE_MASK, 0, 0);
43
+ return node;
44
+ }
45
+ /**
46
+ * Creates `pass(scene, camera)` with MRT `{ output, treeMask }` and returns it with its colour and
47
+ * mask texture nodes. `selection`: the trees to outline (default `null` = all trees), see
48
+ * {@link createTreeMask}. If your pipeline already has a scene pass, merge {@link treeMaskMRT} into it instead.
49
+ */
50
+ function treeEffectsPass(scene, camera, selection = null) {
51
+ const scenePass = pass(scene, camera);
52
+ scenePass.setMRT(mrt({ output }).merge(treeMaskMRT(selection)));
53
+ scenePass.getTexture(TREE_MASK).type = UnsignedByteType;
54
+ return {
55
+ pass: scenePass,
56
+ color: scenePass.getTextureNode("output"),
57
+ mask: scenePass.getTextureNode(TREE_MASK)
58
+ };
59
+ }
60
+ // src/effects/outline.ts
61
+ var D = Math.SQRT1_2;
62
+ var DIRECTIONS = [
63
+ [1, 0],
64
+ [-1, 0],
65
+ [0, 1],
66
+ [0, -1],
67
+ [D, D],
68
+ [D, -D],
69
+ [-D, D],
70
+ [-D, -D]
71
+ ];
72
+ /**
73
+ * Tree Effect: an outline along the silhouettes of the selected trees (the `selection` of the
74
+ * tree mask, see `createTreeMask`; all trees by default), around the outside of the canopy and
75
+ * the gaps in it. The line is drawn on the inside of the silhouette, so only tree pixels change.
76
+ */
77
+ function treeOutline(input, options = {}) {
78
+ const { color: color$2 = "#1d2a14", thickness = 2, strength = 1 } = options;
79
+ const { mask } = input;
80
+ const step = vec2(thickness).div(vec2(textureSize(mask)));
81
+ const centre = uv();
82
+ let outside = float(0);
83
+ for (const [x, y] of DIRECTIONS) outside = outside.add(float(1).sub(mask.sample(centre.add(step.mul(vec2(x, y)))).b));
84
+ const edge = outside.mul(3 / DIRECTIONS.length).clamp(0, 1).mul(mask.sample(centre).b).mul(strength);
85
+ return vec4(mix(input.color.rgb, color(new Color(color$2)), edge), input.color.a);
86
+ }
87
+ // src/effects/glow.ts
88
+ /**
89
+ * Tree Effect: a soft glow of the leaves. The bright (sunlit) leaf pixels are blurred and added
90
+ * back onto the tree pixels (leaves and the wood between them), never onto the rest of the scene.
91
+ */
92
+ function leafGlow(input, options = {}) {
93
+ const { color: color$1 = "#ffffff", intensity = .6, threshold = .15, radius = 6 } = options;
94
+ const bright = smoothstep(threshold, threshold * 2 + .05, luminance(input.color.rgb));
95
+ const leaves = vec4(input.color.rgb.mul(input.mask.g).mul(bright), 1);
96
+ const glow = gaussianBlur(leaves, null, radius, { resolutionScale: .5 }).rgb.mul(color(new Color(color$1))).mul(intensity).mul(input.mask.r);
97
+ return vec4(input.color.rgb.add(glow), input.color.a);
98
+ }
99
+ // src/effects/grade.ts
100
+ var MID_GREY = .18;
101
+ /**
102
+ * Tree Effect: colour grading (exposure, tint, saturation, contrast) of the tree pixels only.
103
+ * Returns the graded colour where the tree mask is set and `input.color` unchanged elsewhere.
104
+ */
105
+ function treeColorGrade(input, options = {}) {
106
+ const { exposure = 1, saturation = 1, contrast = 1, tint = "#ffffff" } = options;
107
+ const tinted = input.color.rgb.mul(color(new Color(tint))).mul(exposure);
108
+ const contrasted = mix(vec3(luminance(tinted)), tinted, saturation).max(0).div(MID_GREY).pow(vec3(float(contrast))).mul(MID_GREY);
109
+ return select(input.mask.r.greaterThan(.5), vec4(contrasted, input.color.a), input.color);
110
+ }
111
+ // src/effects/suggested.ts
112
+ /** The suggested combination of Tree Effects for each built-in Style. */
113
+ var SUGGESTED_TREE_EFFECTS = {
114
+ "low-poly": {
115
+ grade: {
116
+ saturation: 1.15,
117
+ contrast: 1.1
118
+ },
119
+ outline: {
120
+ color: "#18230f",
121
+ thickness: 2,
122
+ strength: .9
123
+ }
124
+ },
125
+ stylized: {
126
+ grade: {
127
+ saturation: .95,
128
+ contrast: 1.08,
129
+ tint: "#fff1e0"
130
+ },
131
+ glow: {
132
+ color: "#fff6c8",
133
+ intensity: .45,
134
+ threshold: .3,
135
+ radius: 8
136
+ },
137
+ outline: {
138
+ color: "#2b3a1c",
139
+ thickness: 2,
140
+ strength: .6
141
+ }
142
+ },
143
+ realistic: {
144
+ grade: {
145
+ exposure: 1.05,
146
+ contrast: 1.08,
147
+ saturation: .95,
148
+ tint: "#fff5e6"
149
+ },
150
+ glow: {
151
+ color: "#e8ffc0",
152
+ intensity: .35,
153
+ threshold: .12,
154
+ radius: 4
155
+ }
156
+ }
157
+ };
158
+ // src/effects/effects.ts
159
+ /**
160
+ * Applies a combination of Tree Effects to `input` and returns the resulting colour node, for use in
161
+ * your own post-processing pipeline (`pipeline.outputNode = applyTreeEffects(...)`, or feed it into
162
+ * more effects). Order: colour grade, leaf glow, outline. Empty settings return `input.color`.
163
+ */
164
+ function applyTreeEffects(input, settings) {
165
+ let color = input.color;
166
+ if (settings.grade) color = treeColorGrade({
167
+ color,
168
+ mask: input.mask
169
+ }, settings.grade);
170
+ if (settings.glow) color = leafGlow({
171
+ color,
172
+ mask: input.mask
173
+ }, settings.glow);
174
+ if (settings.outline) color = treeOutline({
175
+ color,
176
+ mask: input.mask
177
+ }, settings.outline);
178
+ return color;
179
+ }
180
+ function resolveEffects(choice) {
181
+ if (choice === null) return {};
182
+ if (typeof choice !== "string") return choice;
183
+ const settings = SUGGESTED_TREE_EFFECTS[choice];
184
+ if (!settings) throw new Error(`No suggested Tree Effects for Style "${choice}"`);
185
+ return settings;
186
+ }
187
+ /**
188
+ * A ready-made post-processing pipeline (`RenderPipeline`) with the Tree Effects: render with
189
+ * `effects.render()` instead of `renderer.render(scene, camera)`. Switch the combination with
190
+ * `effects.set('stylized')` (e.g. a preview). For your own pipeline, use {@link treeEffectsPass}
191
+ * and {@link applyTreeEffects} instead.
192
+ */
193
+ var TreeEffects = class {
194
+ pipeline;
195
+ /** The scene pass (colour + tree mask). */
196
+ scenePass;
197
+ nodes = [];
198
+ current = {};
199
+ constructor(renderer, scene, camera, options = {}) {
200
+ this.pipeline = new RenderPipeline(renderer);
201
+ this.scenePass = treeEffectsPass(scene, camera, options.selection ?? null);
202
+ this.set(options.effects ?? null);
203
+ }
204
+ /** The active combination (`{}` = none). */
205
+ get settings() {
206
+ return this.current;
207
+ }
208
+ /** Switches to a Style's suggested combination, custom settings, or none (`null`). */
209
+ set(effects) {
210
+ this.current = resolveEffects(effects);
211
+ this.disposeNodes();
212
+ const output = applyTreeEffects(this.scenePass, this.current);
213
+ this.nodes = collectEffectNodes(output, this.scenePass.color);
214
+ this.pipeline.outputNode = output;
215
+ this.pipeline.needsUpdate = true;
216
+ }
217
+ /** Renders the scene with the effects (call instead of `renderer.render(scene, camera)`). */
218
+ render() {
219
+ this.pipeline.render();
220
+ }
221
+ dispose() {
222
+ this.disposeNodes();
223
+ this.scenePass.pass.dispose();
224
+ this.pipeline.dispose();
225
+ }
226
+ disposeNodes() {
227
+ for (const node of this.nodes) node.dispose();
228
+ this.nodes = [];
229
+ }
230
+ };
231
+ /** The render-target owning nodes (blur) in an effects graph, to dispose them on change. */
232
+ function collectEffectNodes(output, stop) {
233
+ const found = /* @__PURE__ */ new Set();
234
+ const visit = (node, seen) => {
235
+ if (seen.has(node) || node === stop) return;
236
+ seen.add(node);
237
+ if (node.isGaussianBlurNode) found.add(node);
238
+ for (const child of node.getChildren()) visit(child, seen);
239
+ };
240
+ visit(output, /* @__PURE__ */ new Set());
241
+ return [...found];
242
+ }
243
+ /** Shorthand for `new TreeEffects(renderer, scene, camera, options)`. */
244
+ function createTreeEffects(renderer, scene, camera, options) {
245
+ return new TreeEffects(renderer, scene, camera, options);
246
+ }
247
+ export { SUGGESTED_TREE_EFFECTS, TREE_MASK, TreeEffects, applyTreeEffects, createTreeEffects, createTreeMask, leafGlow, treeColorGrade, treeEffectsPass, treeMaskMRT, treeOutline, treePartOf };
248
+
249
+ //# sourceMappingURL=effects.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"effects.js","names":["tslColor","color","tslColor","color","tslColor","n"],"sources":["../src/effects/mask.ts","../src/effects/outline.ts","../src/effects/glow.ts","../src/effects/grade.ts","../src/effects/suggested.ts","../src/effects/effects.ts"],"sourcesContent":["import {\n UnsignedByteType,\n Vector4,\n type Camera,\n type Material,\n type MRTNode,\n type Node,\n type Object3D,\n type PassNode,\n type Scene,\n type TextureNode,\n} from 'three/webgpu';\nimport { mrt, output, pass, 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';\n\n/**\n * Which tree part a material draws: 'bark' or 'leaves' 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 : 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, 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\n/** A scene pass that renders the colour and the tree mask, 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 }` and returns it with its colour and\n * mask texture nodes. `selection`: the trees to outline (default `null` = all trees), see\n * {@link createTreeMask}. If your pipeline already has a scene pass, merge {@link treeMaskMRT} into it instead.\n */\nexport function treeEffectsPass(scene: Scene, camera: Camera, selection: readonly Object3D[] | null = null): TreeEffectsPass {\n const scenePass = pass(scene, camera);\n scenePass.setMRT(mrt({ output }).merge(treeMaskMRT(selection)));\n scenePass.getTexture(TREE_MASK).type = UnsignedByteType;\n return { pass: scenePass, color: scenePass.getTextureNode('output'), mask: scenePass.getTextureNode(TREE_MASK) };\n}\n","import { Color, type ColorRepresentation, type Node } from 'three/webgpu';\nimport { color as tslColor, float, mix, textureSize, uv, vec2, vec4 } from 'three/tsl';\nimport type { TreeEffectInput } from './mask';\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\n// Eight sample directions around a pixel (unit length).\nconst D = Math.SQRT1_2;\nconst DIRECTIONS: [number, number][] = [[1, 0], [-1, 0], [0, 1], [0, -1], [D, D], [D, -D], [-D, D], [-D, -D]];\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 */\nexport function treeOutline(input: TreeEffectInput, options: TreeOutlineOptions = {}): Node<'vec4'> {\n const { color = '#1d2a14', thickness = 2, strength = 1 } = options;\n const { mask } = input;\n const step = vec2(thickness).div(vec2(textureSize(mask) as unknown as Node<'ivec2'>));\n const centre = uv();\n // Fraction of neighbours (at `thickness` px) that are not selected tree pixels.\n let outside: Node<'float'> = float(0);\n for (const [x, y] of DIRECTIONS) {\n outside = outside.add(float(1).sub(mask.sample(centre.add(step.mul(vec2(x, y)))).b));\n }\n const edge = outside.mul(3 / DIRECTIONS.length).clamp(0, 1).mul(mask.sample(centre).b).mul(strength);\n return vec4(mix(input.color.rgb, tslColor(new Color(color)), edge), input.color.a);\n}\n","import { Color, type ColorRepresentation, type Node } from 'three/webgpu';\nimport { color as tslColor, luminance, smoothstep, vec4 } from 'three/tsl';\nimport { gaussianBlur } from 'three/addons/tsl/display/GaussianBlurNode.js';\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/**\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 const { color = '#ffffff', intensity = 0.6, threshold = 0.15, radius = 6 } = options;\n const bright = smoothstep(threshold, threshold * 2 + 0.05, luminance(input.color.rgb));\n const leaves = vec4(input.color.rgb.mul(input.mask.g).mul(bright), 1);\n const blurred = gaussianBlur(leaves, null, radius, { resolutionScale: 0.5 });\n const glow = blurred.rgb.mul(tslColor(new Color(color))).mul(intensity).mul(input.mask.r);\n return vec4(input.color.rgb.add(glow), input.color.a);\n}\n","import { Color, type ColorRepresentation, type Node } from 'three/webgpu';\nimport { color as tslColor, float, luminance, mix, select, vec3, vec4 } from 'three/tsl';\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 const { exposure = 1, saturation = 1, contrast = 1, tint = '#ffffff' } = options;\n const tinted = input.color.rgb.mul(tslColor(new Color(tint))).mul(exposure);\n const saturated = mix(vec3(luminance(tinted)), tinted, saturation).max(0);\n const contrasted = saturated.div(MID_GREY).pow(vec3(float(contrast))).mul(MID_GREY);\n return select(input.mask.r.greaterThan(0.5), vec4(contrasted, input.color.a), input.color);\n}\n","import type { StyleName } from '../styles/registry';\nimport type { TreeColorGradeOptions } from './grade';\nimport type { LeafGlowOptions } from './glow';\nimport type { TreeOutlineOptions } from './outline';\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}\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 and slightly punchier colours.\n 'low-poly': {\n grade: { saturation: 1.15, contrast: 1.1 },\n outline: { color: '#18230f', thickness: 2, strength: 0.9 },\n },\n // Storybook look: soft glowing foliage, a warm tint and a soft 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 outline: { color: '#2b3a1c', thickness: 2, strength: 0.6 },\n },\n // Natural: 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 { leafGlow } from './glow';\nimport { treeColorGrade } from './grade';\nimport { treeEffectsPass, type TreeEffectInput, type TreeEffectsPass } from './mask';\nimport { treeOutline } from './outline';\nimport { SUGGESTED_TREE_EFFECTS, type TreeEffectsSettings } from './suggested';\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, outline. Empty settings return `input.color`.\n */\nexport function applyTreeEffects(input: TreeEffectInput, settings: TreeEffectsSettings): Node<'vec4'> {\n let color = input.color;\n if (settings.grade) color = treeColorGrade({ color, mask: input.mask }, settings.grade);\n if (settings.glow) color = leafGlow({ color, mask: input.mask }, settings.glow);\n if (settings.outline) color = treeOutline({ color, mask: input.mask }, settings.outline);\n return color;\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\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 scene pass (colour + tree mask). */\n readonly scenePass: TreeEffectsPass;\n private nodes: Node[] = [];\n private current: TreeEffectsSettings = {};\n\n constructor(renderer: Renderer, scene: Scene, camera: Camera, options: TreeEffectsOptions = {}) {\n this.pipeline = new RenderPipeline(renderer);\n this.scenePass = treeEffectsPass(scene, camera, options.selection ?? null);\n this.set(options.effects ?? null);\n }\n\n /** The active combination (`{}` = none). */\n get settings(): TreeEffectsSettings {\n return this.current;\n }\n\n /** Switches to a Style's suggested combination, custom settings, or none (`null`). */\n set(effects: TreeEffectsChoice): void {\n this.current = resolveEffects(effects);\n this.disposeNodes();\n const output = applyTreeEffects(this.scenePass, this.current);\n this.nodes = collectEffectNodes(output, this.scenePass.color);\n this.pipeline.outputNode = output;\n this.pipeline.needsUpdate = true;\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":";;;;;AAeA,IAAa,YAAY;;;;;AASzB,SAAgB,WAAW,UAAwD;CACjF,MAAM,OAAgB,UAAU,SAAS;CACzC,OAAO,SAAS,UAAU,SAAS,WAAW,OAAO;AACvD;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,OAAO,SAAS;EACtE,MAAM,OAAO,WAAW,MAAM,QAAQ;EACtC,MAAM,WAAW,SAAS,SAAS,cAAc,QAAQ,WAAW,MAAM,QAAQ,SAAS;EAC3F,KAAK,MAAM,IAAI,OAAO,IAAI,GAAG,SAAS,WAAW,IAAI,GAAG,WAAW,IAAI,GAAG,CAAC;CAE7E,CAAC;AACH;;;;;;AAOA,SAAgB,YAAY,YAAwC,MAAe;CACjF,MAAM,OAAO,IAAI,GAAG,YAAY,eAAe,SAAS,EAAE,CAAC;CAC3D,KAAK,cAAc,WAAW,GAAU,CAAC;CACzC,OAAO;AACT;;;;;;AAoBA,SAAgB,gBAAgB,OAAc,QAAgB,YAAwC,MAAuB;CAC3H,MAAM,YAAY,KAAK,OAAO,MAAM;CACpC,UAAU,OAAO,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC,MAAM,YAAY,SAAS,CAAC,CAAC;CAC9D,UAAU,WAAW,SAAS,CAAC,CAAC,OAAO;CACv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AAK,OAAO;EAC5D,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,UAAU,KAAK;EAC5D,KAAK,SAAS,aAAa;EAC3B,KAAK,SAAS,cAAc;CAC9B;;CAGA,SAAe;EACb,KAAK,SAAS,OAAO;CACvB;CAEA,UAAgB;EACd,KAAK,aAAa;EAClB,KAAK,UAAU,KAAK,QAAQ;EAC5B,KAAK,SAAS,QAAQ;CACxB;CAEA,eAA6B;EAC3B,KAAK,MAAM,QAAQ,KAAK,OAAO,KAAK,QAAQ;EAC5C,KAAK,QAAQ,CAAC;CAChB;AACF;;AAGA,SAAS,mBAAmB,QAAc,MAAoB;CAC5D,MAAM,wBAAQ,IAAI,IAAU;CAC5B,MAAM,SAAS,MAAY,SAA0B;EACnD,IAAI,KAAK,IAAI,IAAI,KAAK,SAAS,MAAM;EACrC,KAAK,IAAI,IAAI;EAEb,IAAIC,KAAE,oBAAoB,MAAM,IAAI,IAAI;EACxC,KAAK,MAAM,SAAS,KAAK,YAAY,GAAG,MAAM,OAAe,IAAI;CACnE;CACA,MAAM,wBAAQ,IAAI,IAAI,CAAC;CACvB,OAAO,CAAC,GAAG,KAAK;AAClB;;AAGA,SAAgB,kBAAkB,UAAoB,OAAc,QAAgB,SAA2C;CAC7H,OAAO,IAAI,YAAY,UAAU,OAAO,QAAQ,OAAO;AACzD"}
@@ -0,0 +1,156 @@
1
+ import { BufferGeometry, Group, InstancedMesh, type MeshStandardNodeMaterial } from 'three/webgpu';
2
+ import type { TreeDefinition } from '../definition';
3
+ import { type TreeData } from '../generator';
4
+ import { type TextureOptions } from '../textures';
5
+ import { Wind, WindResponse, type WindSource } from '../wind';
6
+ import { type ForestPlacement, type ForestTreeTraits } from './placement';
7
+ /** Options of {@link createForest}. */
8
+ export interface ForestOptions {
9
+ /** How many Variants (distinct trees, each drawn instanced) the forest is made of. Default 4. */
10
+ variants?: number;
11
+ /** The forest seed: picks the Variants and every tree's Variant and offsets. Default 0. */
12
+ seed?: number;
13
+ /** Growth every tree starts at, 0..1. Default 1 (fully grown). */
14
+ growth?: number;
15
+ /** Season every tree starts at, 0..1. Default 0. */
16
+ season?: number;
17
+ /** The Wind the forest sways with. Default: the scene-wide `sceneWind`. */
18
+ wind?: Wind;
19
+ /** Where the Definition's textures load from (as `createTree(..., { textures })`). */
20
+ textures?: TextureOptions;
21
+ }
22
+ /** What the GPU draws one tree with (after its offsets). */
23
+ export interface ForestInstanceState {
24
+ growth: number;
25
+ season: number;
26
+ windPhase: number;
27
+ }
28
+ /**
29
+ * One tree of a {@link Forest}. Its Variant and offsets come from the forest seed and its key
30
+ * only. `growth` and `season` are what the app sets on this tree; the tree draws them with its
31
+ * offsets applied (see {@link Forest.instanceState}).
32
+ */
33
+ export declare class ForestTree implements ForestTreeTraits {
34
+ private readonly onChange;
35
+ /** The tree's id as a string, or `@x,y,z` (position in mm) when it was placed without an id. */
36
+ readonly key: string;
37
+ readonly placement: Readonly<ForestPlacement>;
38
+ readonly variant: number;
39
+ readonly growthDelay: number;
40
+ readonly seasonShift: number;
41
+ readonly windPhase: number;
42
+ /** @internal Slot in the Variant's instance buffers. */
43
+ slot: number;
44
+ private growthValue;
45
+ private seasonValue;
46
+ /** @internal Use {@link Forest.addTree}. */
47
+ constructor(key: string, placement: ForestPlacement, traits: ForestTreeTraits, state: {
48
+ growth: number;
49
+ season: number;
50
+ }, onChange: (tree: ForestTree) => void);
51
+ /** Growth set on this tree, 0..1 (clamped). Only rewrites this tree's instance data. */
52
+ get growth(): number;
53
+ set growth(value: number);
54
+ /** Season set on this tree, 0..1 (wraps around the year). Only rewrites this tree's instance data. */
55
+ get season(): number;
56
+ set season(value: number);
57
+ }
58
+ /**
59
+ * One Variant of a Forest: one Seed's tree, drawn once per tree that uses it with an instanced
60
+ * wood mesh and an instanced leaf mesh (one draw call per material).
61
+ */
62
+ export declare class ForestVariant {
63
+ private readonly forest;
64
+ readonly index: number;
65
+ readonly seed: number;
66
+ readonly data: TreeData;
67
+ /** This Variant's response to the Wind (trunk height from its Seed; each tree has its own phase). */
68
+ readonly windResponse: WindResponse;
69
+ readonly barkMaterial: MeshStandardNodeMaterial;
70
+ readonly leafMaterial: MeshStandardNodeMaterial;
71
+ /** The trees drawn as this Variant, in instance order. */
72
+ readonly trees: ForestTree[];
73
+ private woodMesh;
74
+ private leafMesh;
75
+ private instanceData;
76
+ private readonly woodSource;
77
+ private readonly leafSource;
78
+ constructor(forest: Forest, definition: TreeDefinition, index: number, seed: number, wind: WindSource, capacity: number, textures?: TextureOptions);
79
+ /** Instanced mesh of trunks and branches. Replaced (not resized) when the Variant outgrows its capacity. */
80
+ get wood(): InstancedMesh<BufferGeometry, MeshStandardNodeMaterial>;
81
+ /** Instanced mesh of the leaves. Replaced along with {@link wood}. */
82
+ get leaves(): InstancedMesh<BufferGeometry, MeshStandardNodeMaterial>;
83
+ get capacity(): number;
84
+ /** @internal */
85
+ add(tree: ForestTree): void;
86
+ /** @internal Swap-removes a tree: the last tree takes its slot. */
87
+ remove(tree: ForestTree): void;
88
+ /** @internal Writes one tree's transform and state into its instance slot. */
89
+ write(tree: ForestTree): void;
90
+ /** @internal */
91
+ state(tree: ForestTree): ForestInstanceState;
92
+ /** @internal Frees the GPU resources. */
93
+ dispose(): void;
94
+ private setCount;
95
+ /**
96
+ * (Re)builds the instanced meshes with room for `capacity` trees. An InstancedMesh cannot grow,
97
+ * so a full Variant gets new meshes (same materials and vertex data) of twice the size.
98
+ */
99
+ private allocate;
100
+ private disposeMeshes;
101
+ }
102
+ /**
103
+ * Many trees of one Tree Definition, drawn from a few shared Variants (one instanced mesh per
104
+ * Variant and material). Each tree's Variant and its small Growth/Season offsets come from a
105
+ * hash of the forest seed and the tree's id (or position), never from its index, so adding or
106
+ * removing trees never changes the others. Growth and Season can be set per tree or for all.
107
+ */
108
+ export declare class Forest extends Group {
109
+ readonly isForest = true;
110
+ readonly definition: TreeDefinition;
111
+ /** The forest seed. */
112
+ readonly seed: number;
113
+ readonly variants: readonly ForestVariant[];
114
+ /** Resolves once every texture has loaded (at once without textures); rejects if one fails. */
115
+ readonly ready: Promise<void>;
116
+ private readonly byKey;
117
+ private readonly windBinding;
118
+ private growthValue;
119
+ private seasonValue;
120
+ constructor(definition: TreeDefinition, placements?: readonly ForestPlacement[], options?: ForestOptions);
121
+ /**
122
+ * The Wind every tree of this forest sways with. Assigning another Wind only rebinds uniforms:
123
+ * no rebuild, no recompile.
124
+ */
125
+ get wind(): Wind;
126
+ set wind(value: Wind);
127
+ /** Every tree, in the order they were added. */
128
+ get trees(): readonly ForestTree[];
129
+ /** Number of trees. */
130
+ get size(): number;
131
+ /** The tree with this key (its id as a string, or `ForestTree.key`). */
132
+ get(key: string | number): ForestTree | undefined;
133
+ /**
134
+ * Plants a tree. Throws if a tree with the same id (or, without ids, the same position) exists.
135
+ * It starts at the forest's current Growth and Season.
136
+ */
137
+ addTree(placement: ForestPlacement): ForestTree;
138
+ /** Cuts a tree (by key or object). Returns false if it is not in this forest. Other trees keep their look. */
139
+ removeTree(tree: ForestTree | string | number): boolean;
140
+ /** The tree drawn by instance `instanceId` of a Variant mesh, e.g. from a raycast intersection. */
141
+ treeAt(intersection: {
142
+ object: unknown;
143
+ instanceId?: number;
144
+ }): ForestTree | undefined;
145
+ /** What the GPU draws a tree with: its Growth and Season after its offsets, and its Wind phase. */
146
+ instanceState(tree: ForestTree | string | number): ForestInstanceState;
147
+ /** Growth of the whole forest: setting it sets every tree's Growth (and that of trees planted later). */
148
+ get growth(): number;
149
+ set growth(value: number);
150
+ /** Season of the whole forest: setting it sets every tree's Season (and that of trees planted later). */
151
+ get season(): number;
152
+ set season(value: number);
153
+ /** Frees every Variant's geometries, materials and instance buffers, and removes the forest from its parent. */
154
+ dispose(): void;
155
+ }
156
+ //# sourceMappingURL=Forest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Forest.d.ts","sourceRoot":"","sources":["../../src/forest/Forest.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EAGd,KAAK,EAGL,aAAa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AAO,EAAE,OAAO,GAAE,aAAkB;IAsBhH;;;OAGG;IACH,IAAI,IAAI,IAAI,IAAI,CAEf;IAED,IAAI,IAAI,CAAC,KAAK,EAAE,IAAI,EAEnB;IAED,gDAAgD;IAChD,IAAI,KAAK,IAAI,SAAS,UAAU,EAAE,CAEjC;IAED,uBAAuB;IACvB,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,wEAAwE;IACxE,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,UAAU,GAAG,SAAS;IAIjD;;;OAGG;IACH,OAAO,CAAC,SAAS,EAAE,eAAe,GAAG,UAAU;IAuB/C,8GAA8G;IAC9G,UAAU,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO;IAQvD,mGAAmG;IACnG,MAAM,CAAC,YAAY,EAAE;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,UAAU,GAAG,SAAS;IAKtF,mGAAmG;IACnG,aAAa,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,mBAAmB;IAMtE,yGAAyG;IACzG,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,IAAI,MAAM,CAAC,KAAK,EAAE,MAAM,EAGvB;IAED,yGAAyG;IACzG,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,IAAI,MAAM,CAAC,KAAK,EAAE,MAAM,EAGvB;IAED,gHAAgH;IACvG,OAAO,IAAI,IAAI;CAMzB"}
@@ -0,0 +1,14 @@
1
+ import { type TreeDefinition, type TreeDefinitionInput } from '../definition';
2
+ import { Forest, type ForestOptions } from './Forest';
3
+ import type { ForestPlacement } from './placement';
4
+ export { Forest, ForestTree, ForestVariant, type ForestOptions, type ForestInstanceState } from './Forest';
5
+ export type { ForestPlacement, ForestTreeTraits } from './placement';
6
+ /**
7
+ * Places many trees of one Tree Definition cheaply: `variants` Seeds are generated once and each
8
+ * is drawn instanced. Each tree's Variant and small Growth/Season offsets come from a hash of
9
+ * the forest `seed` and the tree's id (or position), so the same seed and placements always give
10
+ * the same forest, and adding or removing a tree never changes the others.
11
+ * Throws `TreeDefinitionError` for an invalid Definition.
12
+ */
13
+ export declare function createForest(definition: TreeDefinitionInput | TreeDefinition, placements?: readonly ForestPlacement[], options?: ForestOptions): Forest;
14
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/forest/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,cAAc,EAAE,KAAK,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,MAAM,EAAE,KAAK,aAAa,EAAE,MAAM,UAAU,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,KAAK,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC3G,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAErE;;;;;;GAMG;AACH,wBAAgB,YAAY,CAC1B,UAAU,EAAE,mBAAmB,GAAG,cAAc,EAChD,UAAU,GAAE,SAAS,eAAe,EAAO,EAC3C,OAAO,GAAE,aAAkB,GAC1B,MAAM,CAER"}
@@ -0,0 +1,31 @@
1
+ import type { Node } from 'three/webgpu';
2
+ import { type WindResponse, type WindSource } from '../wind';
3
+ /**
4
+ * Per-instance data of a Forest (one interleaved instanced buffer, 8 floats per tree):
5
+ * `iRotation` = the tree's rotation as a quaternion (x, y, z, w);
6
+ * `iState` = (scale, Growth, Season, Wind phase), Growth/Season already include the tree's offsets.
7
+ */
8
+ export declare const INSTANCE_STRIDE = 8;
9
+ export declare const INSTANCE_ATTRIBUTES: {
10
+ readonly iRotation: 0;
11
+ readonly iState: 4;
12
+ };
13
+ /** Per-tree values in the instanced Season/Growth/Wind slots. */
14
+ export declare function instanceState(): {
15
+ scale: Node<'float'>;
16
+ growth: Node<'float'>;
17
+ season: Node<'float'>;
18
+ windPhase: Node<'float'>;
19
+ };
20
+ /**
21
+ * The vertex position of a Forest tree (positionNode of an instanced Variant mesh).
22
+ *
23
+ * On an InstancedMesh, three.js applies the instance matrix to `positionLocal` before
24
+ * `positionNode` runs, but Growth and Wind are defined in the tree's own space (about the
25
+ * generated `aOrigin`s, relative to its trunk height). So both are computed from
26
+ * `positionGeometry`, and only their displacement is turned into forest space with the
27
+ * instance rotation and scale: M·(p + d) = M·p + R·s·d. The Wind direction goes the other way
28
+ * (forest -> tree space) and each tree sways with its own phase.
29
+ */
30
+ export declare function forestPosition(wind: WindSource, response: WindResponse): Node<'vec3'>;
31
+ //# sourceMappingURL=nodes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../src/forest/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EAAmC,KAAK,YAAY,EAAE,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AAE9F;;;;GAIG;AACH,eAAO,MAAM,eAAe,IAAI,CAAC;AACjC,eAAO,MAAM,mBAAmB;;;CAAuC,CAAC;AAExE,iEAAiE;AACjE,wBAAgB,aAAa,IAAI;IAAE,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IAAC,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,CAAA;CAAE,CAGhI;AAUD;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,CAMrF"}
@@ -0,0 +1,52 @@
1
+ import type { VariationDefinition } from '../definition';
2
+ import type { Vec3 } from '../generator';
3
+ /** Where one tree of a Forest stands. */
4
+ export interface ForestPlacement {
5
+ /** Position of the tree base, in the Forest's space. */
6
+ position: Vec3 | {
7
+ x: number;
8
+ y: number;
9
+ z: number;
10
+ };
11
+ /** Radians: a number turns the tree about the vertical (Y) axis; [x, y, z] is an Euler rotation (XYZ order). Default 0. */
12
+ rotation?: number | Vec3;
13
+ /** Uniform scale. Default 1. */
14
+ scale?: number;
15
+ /**
16
+ * A stable id. A tree's Variant and offsets come from it, so the tree keeps its look when it is
17
+ * moved. Without an id they come from the position (rounded to 1 mm).
18
+ */
19
+ id?: string | number;
20
+ }
21
+ /** What the forest seed and a tree's key decide about that tree. */
22
+ export interface ForestTreeTraits {
23
+ /** Which Variant (0 .. variants-1) the tree is drawn as. */
24
+ variant: number;
25
+ /** 0 .. `variation.growth`: how far behind the forest's Growth this tree grows. */
26
+ growthDelay: number;
27
+ /** Within ± `variation.season`: how far this tree's Season is shifted. */
28
+ seasonShift: number;
29
+ /** Radians, 0 .. 2π: so trees of one Variant do not sway in step. */
30
+ windPhase: number;
31
+ }
32
+ export declare function placementPosition(placement: ForestPlacement): Vec3;
33
+ /**
34
+ * The key a tree is known by: its id as a string (so ids 1 and "1" are the same tree), or
35
+ * `@x,y,z` (position in millimetres) when it has no id.
36
+ */
37
+ export declare function forestTreeKey(placement: ForestPlacement): string;
38
+ /** The Seed of Variant `index` of a forest. */
39
+ export declare function variantSeed(forestSeed: number, index: number): number;
40
+ /**
41
+ * A tree's Variant and offsets: a hash of the forest seed and the tree's key only, so they never
42
+ * depend on the tree's index in the list or on which other trees exist.
43
+ */
44
+ export declare function forestTreeTraits(forestSeed: number, key: string, variants: number, variation: Pick<VariationDefinition, 'growth' | 'season'>): ForestTreeTraits;
45
+ /**
46
+ * The Growth one tree is drawn at, for a Growth `growth` set on it: delayed by its `growthDelay`
47
+ * but still exactly 0 at Growth 0 and 1 at Growth 1, so a fully grown forest is fully grown.
48
+ */
49
+ export declare function delayedGrowth(growth: number, delay: number): number;
50
+ /** The Season one tree is drawn at: the Season set on it plus its shift, wrapped into 0..1. */
51
+ export declare function shiftedSeason(season: number, shift: number): number;
52
+ //# sourceMappingURL=placement.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"placement.d.ts","sourceRoot":"","sources":["../../src/forest/placement.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACzD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAKzC,yCAAyC;AACzC,MAAM,WAAW,eAAe;IAC9B,wDAAwD;IACxD,QAAQ,EAAE,IAAI,GAAG;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACrD,2HAA2H;IAC3H,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,gCAAgC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACtB;AAED,oEAAoE;AACpE,MAAM,WAAW,gBAAgB;IAC/B,4DAA4D;IAC5D,OAAO,EAAE,MAAM,CAAC;IAChB,mFAAmF;IACnF,WAAW,EAAE,MAAM,CAAC;IACpB,0EAA0E;IAC1E,WAAW,EAAE,MAAM,CAAC;IACpB,qEAAqE;IACrE,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,eAAe,GAAG,IAAI,CAKlE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,eAAe,GAAG,MAAM,CAIhE;AAED,+CAA+C;AAC/C,wBAAgB,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAErE;AAED;;;GAGG;AACH,wBAAgB,gBAA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