@casmo/tree.js 0.1.1 → 0.3.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 (220) hide show
  1. package/README.md +312 -16
  2. package/dist/apply-Cio2t7CZ.js +285 -0
  3. package/dist/apply-Cio2t7CZ.js.map +1 -0
  4. package/dist/bake/index.d.ts +44 -5
  5. package/dist/bake/index.d.ts.map +1 -1
  6. package/dist/definition/crown-shape.d.ts +9 -0
  7. package/dist/definition/crown-shape.d.ts.map +1 -0
  8. package/dist/definition/defaults.d.ts +15 -1
  9. package/dist/definition/defaults.d.ts.map +1 -1
  10. package/dist/definition/index.d.ts +4 -3
  11. package/dist/definition/index.d.ts.map +1 -1
  12. package/dist/definition/migrations.d.ts +0 -8
  13. package/dist/definition/migrations.d.ts.map +1 -1
  14. package/dist/definition/schema.d.ts.map +1 -1
  15. package/dist/definition/types.d.ts +181 -6
  16. package/dist/definition/types.d.ts.map +1 -1
  17. package/dist/effects/mask.d.ts +3 -3
  18. package/dist/effects/mask.d.ts.map +1 -1
  19. package/dist/effects.js +3 -3
  20. package/dist/effects.js.map +1 -1
  21. package/dist/forest/Forest.d.ts +37 -2
  22. package/dist/forest/Forest.d.ts.map +1 -1
  23. package/dist/forest/nodes.d.ts +6 -1
  24. package/dist/forest/nodes.d.ts.map +1 -1
  25. package/dist/{forest-OX9WvAwh.js → forest-ChEaWJrf.js} +1763 -684
  26. package/dist/forest-ChEaWJrf.js.map +1 -0
  27. package/dist/generator/branches.d.ts +2 -2
  28. package/dist/generator/branches.d.ts.map +1 -1
  29. package/dist/generator/crown.d.ts +28 -0
  30. package/dist/generator/crown.d.ts.map +1 -0
  31. package/dist/generator/fruit.d.ts +28 -0
  32. package/dist/generator/fruit.d.ts.map +1 -0
  33. package/dist/generator/growth.d.ts +1 -1
  34. package/dist/generator/growth.d.ts.map +1 -1
  35. package/dist/generator/index.d.ts +5 -4
  36. package/dist/generator/index.d.ts.map +1 -1
  37. package/dist/generator/leaf-shapes.d.ts +33 -1
  38. package/dist/generator/leaf-shapes.d.ts.map +1 -1
  39. package/dist/generator/mesh.d.ts +10 -2
  40. package/dist/generator/mesh.d.ts.map +1 -1
  41. package/dist/generator/occlusion.d.ts +8 -0
  42. package/dist/generator/occlusion.d.ts.map +1 -0
  43. package/dist/generator/roots.d.ts +16 -0
  44. package/dist/generator/roots.d.ts.map +1 -0
  45. package/dist/generator/trunk.d.ts +16 -2
  46. package/dist/generator/trunk.d.ts.map +1 -1
  47. package/dist/generator/types.d.ts +61 -6
  48. package/dist/generator/types.d.ts.map +1 -1
  49. package/dist/growth/index.d.ts +1 -1
  50. package/dist/growth/index.d.ts.map +1 -1
  51. package/dist/growth/tsl.d.ts +2 -0
  52. package/dist/growth/tsl.d.ts.map +1 -1
  53. package/dist/index.d.ts +6 -3
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/index.js +274 -24
  56. package/dist/index.js.map +1 -1
  57. package/dist/materials/crown-nodes.d.ts +20 -0
  58. package/dist/materials/crown-nodes.d.ts.map +1 -0
  59. package/dist/materials/crown-normals.d.ts +17 -0
  60. package/dist/materials/crown-normals.d.ts.map +1 -0
  61. package/dist/materials/ground-tint.d.ts +13 -0
  62. package/dist/materials/ground-tint.d.ts.map +1 -0
  63. package/dist/materials/index.d.ts +13 -1
  64. package/dist/materials/index.d.ts.map +1 -1
  65. package/dist/materials/leaf-translucency-model.d.ts +14 -0
  66. package/dist/materials/leaf-translucency-model.d.ts.map +1 -0
  67. package/dist/materials/leaf-translucency.d.ts +73 -0
  68. package/dist/materials/leaf-translucency.d.ts.map +1 -0
  69. package/dist/materials/material-features.d.ts +43 -0
  70. package/dist/materials/material-features.d.ts.map +1 -0
  71. package/dist/materials/occlusion.d.ts +10 -0
  72. package/dist/materials/occlusion.d.ts.map +1 -0
  73. package/dist/materials/toon.d.ts +18 -1
  74. package/dist/materials/toon.d.ts.map +1 -1
  75. package/dist/names-BE9he6CS.js +713 -0
  76. package/dist/names-BE9he6CS.js.map +1 -0
  77. package/dist/react/Tree.d.ts +5 -2
  78. package/dist/react/Tree.d.ts.map +1 -1
  79. package/dist/react.js +10 -6
  80. package/dist/react.js.map +1 -1
  81. package/dist/season/nodes.d.ts +16 -0
  82. package/dist/season/nodes.d.ts.map +1 -1
  83. package/dist/season/profile.d.ts +26 -0
  84. package/dist/season/profile.d.ts.map +1 -1
  85. package/dist/species/almond.js +223 -0
  86. package/dist/species/almond.js.map +1 -0
  87. package/dist/species/almond.json +210 -0
  88. package/dist/species/apple.js +230 -0
  89. package/dist/species/apple.js.map +1 -0
  90. package/dist/species/apple.json +220 -0
  91. package/dist/species/ash.js +187 -0
  92. package/dist/species/ash.js.map +1 -0
  93. package/dist/species/ash.json +177 -0
  94. package/dist/species/beech.js +174 -0
  95. package/dist/species/beech.js.map +1 -0
  96. package/dist/species/beech.json +167 -0
  97. package/dist/species/birch.js +170 -0
  98. package/dist/species/birch.js.map +1 -0
  99. package/dist/species/birch.json +163 -0
  100. package/dist/species/catalog.d.ts +61 -0
  101. package/dist/species/catalog.d.ts.map +1 -0
  102. package/dist/species/cedar.js +169 -0
  103. package/dist/species/cedar.js.map +1 -0
  104. package/dist/species/cedar.json +168 -0
  105. package/dist/species/cherry.js +237 -0
  106. package/dist/species/cherry.js.map +1 -0
  107. package/dist/species/cherry.json +224 -0
  108. package/dist/species/chestnut.js +230 -0
  109. package/dist/species/chestnut.js.map +1 -0
  110. package/dist/species/chestnut.json +220 -0
  111. package/dist/species/douglas-fir.js +174 -0
  112. package/dist/species/douglas-fir.js.map +1 -0
  113. package/dist/species/douglas-fir.json +170 -0
  114. package/dist/species/elm.js +173 -0
  115. package/dist/species/elm.js.map +1 -0
  116. package/dist/species/elm.json +163 -0
  117. package/dist/species/hemlock.js +175 -0
  118. package/dist/species/hemlock.js.map +1 -0
  119. package/dist/species/hemlock.json +171 -0
  120. package/dist/species/hickory.js +200 -0
  121. package/dist/species/hickory.js.map +1 -0
  122. package/dist/species/hickory.json +192 -0
  123. package/dist/species/index.d.ts +10 -0
  124. package/dist/species/index.d.ts.map +1 -0
  125. package/dist/species/juniper.js +158 -0
  126. package/dist/species/juniper.js.map +1 -0
  127. package/dist/species/juniper.json +154 -0
  128. package/dist/species/loaders.d.ts +7 -0
  129. package/dist/species/loaders.d.ts.map +1 -0
  130. package/dist/species/mahogany.js +201 -0
  131. package/dist/species/mahogany.js.map +1 -0
  132. package/dist/species/mahogany.json +196 -0
  133. package/dist/species/maple.js +177 -0
  134. package/dist/species/maple.js.map +1 -0
  135. package/dist/species/maple.json +171 -0
  136. package/dist/species/oak.js +220 -0
  137. package/dist/species/oak.js.map +1 -0
  138. package/dist/species/oak.json +212 -0
  139. package/dist/species/olive.js +189 -0
  140. package/dist/species/olive.js.map +1 -0
  141. package/dist/species/olive.json +181 -0
  142. package/dist/species/peach.js +223 -0
  143. package/dist/species/peach.js.map +1 -0
  144. package/dist/species/peach.json +210 -0
  145. package/dist/species/pear.js +213 -0
  146. package/dist/species/pear.js.map +1 -0
  147. package/dist/species/pear.json +200 -0
  148. package/dist/species/pine.js +163 -0
  149. package/dist/species/pine.js.map +1 -0
  150. package/dist/species/pine.json +162 -0
  151. package/dist/species/plum.js +237 -0
  152. package/dist/species/plum.js.map +1 -0
  153. package/dist/species/plum.json +224 -0
  154. package/dist/species/red-oak.js +220 -0
  155. package/dist/species/red-oak.js.map +1 -0
  156. package/dist/species/red-oak.json +212 -0
  157. package/dist/species/redwood.js +174 -0
  158. package/dist/species/redwood.js.map +1 -0
  159. package/dist/species/redwood.json +170 -0
  160. package/dist/species/sequoia.js +167 -0
  161. package/dist/species/sequoia.js.map +1 -0
  162. package/dist/species/sequoia.json +166 -0
  163. package/dist/species/spruce.js +170 -0
  164. package/dist/species/spruce.js.map +1 -0
  165. package/dist/species/spruce.json +166 -0
  166. package/dist/species/teak.js +166 -0
  167. package/dist/species/teak.js.map +1 -0
  168. package/dist/species/teak.json +157 -0
  169. package/dist/species/types.d.ts +65 -0
  170. package/dist/species/types.d.ts.map +1 -0
  171. package/dist/species/walnut.js +220 -0
  172. package/dist/species/walnut.js.map +1 -0
  173. package/dist/species/walnut.json +212 -0
  174. package/dist/species/white-oak.js +213 -0
  175. package/dist/species/white-oak.js.map +1 -0
  176. package/dist/species/white-oak.json +208 -0
  177. package/dist/species.js +160 -0
  178. package/dist/species.js.map +1 -0
  179. package/dist/styles/apply.d.ts +12 -0
  180. package/dist/styles/apply.d.ts.map +1 -0
  181. package/dist/styles/low-poly/index.d.ts +1 -1
  182. package/dist/styles/low-poly/index.d.ts.map +1 -1
  183. package/dist/styles/low-poly.js +13 -10
  184. package/dist/styles/low-poly.js.map +1 -1
  185. package/dist/styles/material-features.d.ts +27 -0
  186. package/dist/styles/material-features.d.ts.map +1 -0
  187. package/dist/styles/names.d.ts +28 -0
  188. package/dist/styles/names.d.ts.map +1 -0
  189. package/dist/styles/realistic/index.d.ts +3 -8
  190. package/dist/styles/realistic/index.d.ts.map +1 -1
  191. package/dist/styles/realistic/textures.d.ts +20 -0
  192. package/dist/styles/realistic/textures.d.ts.map +1 -0
  193. package/dist/styles/realistic.js +14 -18
  194. package/dist/styles/realistic.js.map +1 -1
  195. package/dist/styles/registry.d.ts +2 -13
  196. package/dist/styles/registry.d.ts.map +1 -1
  197. package/dist/styles/stylized/index.d.ts +1 -1
  198. package/dist/styles/stylized/index.d.ts.map +1 -1
  199. package/dist/styles/stylized.js +13 -10
  200. package/dist/styles/stylized.js.map +1 -1
  201. package/dist/styles/types.d.ts +16 -2
  202. package/dist/styles/types.d.ts.map +1 -1
  203. package/dist/textures/realistic/bark-fibrous-normal.png +0 -0
  204. package/dist/textures/realistic/bark-fibrous.png +0 -0
  205. package/dist/textures/realistic/bark-papery-normal.png +0 -0
  206. package/dist/textures/realistic/bark-papery.png +0 -0
  207. package/dist/textures/realistic/bark-plated-normal.png +0 -0
  208. package/dist/textures/realistic/bark-plated.png +0 -0
  209. package/dist/textures/realistic/bark-smooth-normal.png +0 -0
  210. package/dist/textures/realistic/bark-smooth.png +0 -0
  211. package/dist/textures/realistic/leaf-compound.png +0 -0
  212. package/dist/textures/realistic/leaf-lobed.png +0 -0
  213. package/dist/textures/realistic/leaf-palmate.png +0 -0
  214. package/dist/textures/realistic/scale.png +0 -0
  215. package/dist/tree/Tree.d.ts +34 -5
  216. package/dist/tree/Tree.d.ts.map +1 -1
  217. package/package.json +9 -2
  218. package/dist/forest-OX9WvAwh.js.map +0 -1
  219. package/dist/types-BZjHhNz7.js +0 -20
  220. package/dist/types-BZjHhNz7.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"names-BE9he6CS.js","names":[],"sources":["../src/definition/types.ts","../src/definition/crown-shape.ts","../src/definition/defaults.ts","../src/definition/migrations.ts","../src/definition/schema.ts","../src/definition/parse.ts","../src/styles/material-features.ts","../src/styles/names.ts"],"sourcesContent":["/**\n * Tree Definition schema (see GLOSSARY.md). Plain JSON: it is what the Tree Editor exports\n * and what `createTree` consumes. Every field is documented with its unit and allowed range;\n * the runtime rules live in `schema.ts` and the defaults in `defaults.ts`.\n *\n * Conventions: lengths in metres (scene units), angles in degrees, colours as `#rrggbb`,\n * \"fraction\" fields are 0..1. Fields named `*Variation` are Seed ranges: the Seed picks a\n * value within ± that fraction of the base value.\n */\n\n/**\n * Current Tree Definition schema version. Bump it, and add a migration in `migrations.ts`,\n * whenever the format changes or a generator change would alter existing trees (ADR 0003).\n */\nexport const CURRENT_SCHEMA_VERSION = 3;\n\n/** `#rrggbb` colour string. */\nexport type HexColor = string;\n\n/** [x, y, z] */\nexport type Vec3Tuple = [number, number, number];\n\n/**\n * Form: a label that groups trees (a Style's `broadleaf` / `conifer` Definition). It never\n * changes geometry and is not part of the Tree Definition; a crown's shape comes from its\n * Crown Shape curves (ADR 0004).\n */\nexport type TreeForm = 'broadleaf' | 'conifer';\n\n/** Trunk parameters (branch level 0). */\nexport interface TrunkDefinition {\n /** Trunk length at full Growth, metres (> 0). */\n length: number;\n /** Radius at the base, metres (> 0). */\n radius: number;\n /** Tip radius as a fraction of the base radius (0 = point, 1 = cylinder). */\n taper: number;\n /** Number of sides around the trunk (integer >= 3). */\n sides: number;\n /** Number of sections along the trunk (integer >= 1). */\n sections: number;\n /** Seed range: the Seed scales length by up to ± this fraction (0..1). */\n lengthVariation: number;\n /** Seed range: maximum sideways drift per section, as a fraction of the section length (0..1). */\n bend: number;\n /**\n * Number of Stems growing from the ground (integer >= 1). Each Stem is a full trunk with these\n * parameters and the full branch structure; Stem paths are \"0\", \"1\", \"2\", ... Absent = 1 (a single trunk).\n */\n stems?: number;\n /**\n * How far each Stem leans out from vertical, degrees (0..90). The Seed varies it per Stem\n * (± 30 %) and turns the ring of Stems. Absent = 0 (upright).\n */\n spread?: number;\n /**\n * Pull on the leader, the upper third of each Stem (−1..1): − makes it nod over (a hemlock's\n * drooping tip), + pulls a leaning Stem back up. The lower trunk is never bent. Absent = 0 (none).\n */\n gravity?: number;\n /**\n * Root Flare (0..1): how much each Stem widens towards the ground over the bottom of its length.\n * 1 makes the base ring 1.8 × the trunk radius. Geometry only (ADR 0007): branches, leaves, Fruit,\n * Growth, Wind and Sculpts never move. Absent = 0 (none).\n */\n flare?: number;\n /**\n * Number of extra sections the trunk sweep puts in the Root Flare (integer >= 1), set by the Style\n * like `sides` and `sections`: 2 in low-poly, 3 in the others. Unused without flare. Absent = 3.\n */\n flareSections?: number;\n}\n\n/**\n * One level of branching. `branches[0]` grows from the trunk, `branches[1]` from the\n * level-1 branches, and so on (at most {@link MAX_BRANCH_LEVELS} levels).\n */\nexport interface BranchLevelDefinition {\n /** Child branches per parent branch (integer >= 0). */\n count: number;\n /** Where along the parent children start, as a fraction of the parent length (0..1). */\n start: number;\n /** Where along the parent children stop, as a fraction of the parent length (0..1, >= start). */\n end: number;\n /** Angle between parent and child direction, degrees (0..180). */\n angle: number;\n /** Seed range: ± this fraction of `angle` (0..1). */\n angleVariation: number;\n /** Rotation around the parent between successive children, degrees (0..360; 137.5 = golden angle). */\n spiral: number;\n /** Child length as a fraction of the parent's length (> 0). */\n length: number;\n /** Seed range: ± this fraction of `length` (0..1). */\n lengthVariation: number;\n /** Child base radius as a fraction of the parent's radius where it attaches (0..1). */\n radius: number;\n /** Tip radius as a fraction of the base radius (0..1). */\n taper: number;\n /** Number of sides around each branch (integer >= 3). */\n sides: number;\n /** Number of sections along each branch (integer >= 1). */\n sections: number;\n /** Seed range: maximum sideways drift per section, as a fraction of the section length (0..1). */\n bend: number;\n /** Upward (+) or downward (−) pull on the branch tip (−1..1). */\n gravity: number;\n /**\n * Crown Shape: multiplies `length` by the attach position on the parent (`t` 0 = base .. 1 = tip),\n * values >= 0. Linear between keyframes, holding the first/last value outside them. Absent = flat (1).\n * E.g. a cone: `[{ t: start, value: 1 }, { t: 1, value: 0.1 }]`.\n */\n lengthProfile?: Keyframe<number>[];\n /** Crown Shape: multiplies `angle` by the attach position on the parent, like `lengthProfile` (values >= 0; the angle stays <= 180). */\n angleProfile?: Keyframe<number>[];\n}\n\n/** Maximum number of branching levels below the trunk. */\nexport const MAX_BRANCH_LEVELS = 4;\n\n/**\n * How a leaf is drawn: a flat card, a faceted clump of foliage, a needle cluster, or a puff\n * (a smooth round ball of foliage, for toon shading).\n */\nexport type LeafShape = 'card' | 'clump' | 'needle' | 'puff';\n\n/**\n * Leaf Type: the kind of leaf a Species has. Each Style decides how to draw it (leaf shape,\n * count, size, texture); in a Tree Definition it is a label that never changes geometry by itself.\n */\nexport type LeafType = 'broad' | 'lobed' | 'palmate' | 'compound' | 'needle' | 'scale';\n/** All Leaf Types. */\nexport const LEAF_TYPES: readonly LeafType[] = ['broad', 'lobed', 'palmate', 'compound', 'needle', 'scale'];\n\n/**\n * Bark Type: the kind of bark surface a Species has. Each Style decides how to draw it (colour\n * only, or a texture); in a Tree Definition it is a label that never changes geometry by itself.\n */\nexport type BarkType = 'furrowed' | 'smooth' | 'papery' | 'fibrous' | 'plated';\n/** All Bark Types. */\nexport const BARK_TYPES: readonly BarkType[] = ['furrowed', 'smooth', 'papery', 'fibrous', 'plated'];\n\n/** Leaves, placed on the last branching level (or the trunk if there are no branches). */\nexport interface LeavesDefinition {\n /** Leaf Type the leaves were drawn from (set by `Style.apply`), so a Style can be re-applied. Optional. */\n type?: LeafType;\n /** Leaves per terminal branch (integer >= 0; 0 = no leaves). */\n count: number;\n /** Leaf shape. */\n shape: LeafShape;\n /** Leaf size (width and length of a card / clump diameter), metres (> 0). */\n size: number;\n /** Seed range: ± this fraction of `size` (0..1). */\n sizeVariation: number;\n /** Where along the terminal branch leaves start, as a fraction of its length (0..1). */\n start: number;\n /** Angle between branch and leaf, degrees (0..180). */\n angle: number;\n}\n\n/**\n * Fruit Type: the kind of Fruit a tree bears. `round` (apple, cherry, plum), `pear`, `nut` (a\n * spiky husk, e.g. chestnut), `cone` (conifer cones) or `berry` (small, e.g. juniper).\n */\nexport type FruitType = 'round' | 'pear' | 'nut' | 'cone' | 'berry';\n\n/** Every Fruit Type. */\nexport const FRUIT_TYPES: readonly FruitType[] = ['round', 'pear', 'nut', 'cone', 'berry'];\n\n/**\n * Fruit (ADR 0006): its own tree part, grown on the outermost twigs (the trunk if there are no\n * branch levels) from its own random stream, drawn as small solid shapes in the `fruit` mesh.\n * Absent = no Fruit. Season comes from the Season Profile's `fruit` and `fruitColor` tracks.\n */\nexport interface FruitDefinition {\n /** Fruit Type (shape). */\n type: FruitType;\n /**\n * Fruit per outermost twig (>= 0). A fraction is a chance: 0.3 = one Fruit on about 30% of the\n * twigs, 1.5 = one on every twig and a second on about half (which twigs comes from the Seed).\n */\n count: number;\n /** Fruit length (and about its diameter), metres (> 0). */\n size: number;\n /** Seed range: ± this fraction of `size` (0..1). */\n sizeVariation: number;\n /** How far the Fruit dangles below its twig (0 = sits on the twig pointing outward .. 1 = hangs straight down). */\n hang: number;\n /**\n * Polygon detail, set by the Style: faces around each Fruit (3..16). 5 or fewer also gives a coarse\n * profile (a few flat facets, low-poly). Absent = the Fruit Type's own smooth template.\n */\n sides?: number;\n}\n\n/**\n * Roots (ADR 0007): their own tree part, grown after the Sculpt pass from the Root Flare of every\n * remaining Stem, each from its own random stream, and drawn in the wood mesh after the branches.\n * They run outward and down, taper to a point below the ground, grow with the trunk and never sway.\n * They are not Sculptable. Absent = no Roots.\n */\nexport interface RootsDefinition {\n /** Roots per Stem (integer 0..12). */\n count: number;\n /** Root length as a fraction of its Stem's length (after Seed variation and Sculpts), 0..1. */\n length: number;\n /** Seed range: ± this fraction of `length` (0..1). */\n lengthVariation: number;\n /** Base radius as a fraction of the trunk's base radius (0..1). */\n radius: number;\n /** How steeply a Root dives, degrees below horizontal (0..60). Every Root still ends below the ground. */\n angle: number;\n /** Seed range: sideways wander per section (0..1). */\n bend: number;\n /** Polygon detail, set by the Style: sides around each Root (integer 3..16). Absent = derived from `trunk.sides`. */\n sides?: number;\n /** Polygon detail, set by the Style: sections along each Root (integer >= 1). Absent = 4. */\n sections?: number;\n}\n\n/** Material shading model. Low-poly uses `flat`, stylized `toon`, realistic `standard`. */\nexport type Shading = 'standard' | 'flat' | 'toon';\n\nexport interface BarkMaterialDefinition {\n /** Bark Type the bark was drawn from (set by `Style.apply`), so a Style can be re-applied. Optional. */\n type?: BarkType;\n /** Base bark colour. */\n color: HexColor;\n /** PBR roughness (0..1). */\n roughness: number;\n /** Colour texture URL (resolved against the app's texture base path), or null for none. */\n map: string | null;\n /** Normal map URL, or null for none. */\n normalMap: string | null;\n /** Ground Tint: a darker or mossy bark colour near the ground. Optional; absent = none. */\n groundTint?: GroundTintDefinition;\n}\n\n/**\n * Ground Tint: at and below the ground (tree-space height <= 0, measured on the grown tree) the\n * bark colour blends towards `color` by `strength`; the blend fades smoothly to nothing at `height`.\n */\nexport interface GroundTintDefinition {\n /** The colour the bark blends towards near the ground. */\n color: HexColor;\n /** Metres above the ground where the tint has faded out (> 0). */\n height: number;\n /** How far the bark blends towards `color` at the ground (0..1). */\n strength: number;\n}\n\nexport interface LeafMaterialDefinition {\n /** PBR roughness (0..1). Leaf colour comes from the Season Profile. */\n roughness: number;\n /** Leaf card texture URL (alpha cut-out), or null for none. */\n map: string | null;\n /** Alpha cut-off for `map` (0..1). */\n alphaTest: number;\n /**\n * Crown Normals (a Material Feature, ADR 0008): how far each leaf's normal bends towards the\n * Crown Volume's normal, 0 (each leaf lit on its own) .. 1 (the crown lit as one shape). Absent or 0 = off.\n */\n crownNormals?: number;\n /** Leaf Translucency (a Material Feature, ADR 0008). Absent = off. */\n translucency?: TranslucencyDefinition;\n}\n\n/**\n * Leaf Translucency: light shining through the leaves towards the viewer makes them glow in their\n * own (Season) colour, more at the thin edge of the crown. All plain numbers, 0..1.\n */\nexport interface TranslucencyDefinition {\n /** How strongly leaves with a direct light behind them glow (0..1). */\n strength: number;\n /** Extra glow at the thin edge of the Crown Volume (0 = the same everywhere .. 1 = only at the edge). */\n edge: number;\n /** The indirect (sky) part shining through the canopy, dimmed by occlusion (0..1). */\n ambient: number;\n}\n\n/** Structural Occlusion: ambient light darkened where the tree hides itself (wood, leaves and Fruit). */\nexport interface OcclusionDefinition {\n /** How far the baked occlusion darkens ambient and indirect light (0 = none .. 1 = fully). */\n strength: number;\n}\n\n/**\n * The three Material Features (GLOSSARY, ADR 0008), with the same shapes as in a Definition\n * (`materials.leaf.crownNormals`, `materials.leaf.translucency`, `materials.occlusion`). Absent = off.\n */\nexport interface MaterialFeatures {\n crownNormals?: number;\n translucency?: TranslucencyDefinition;\n occlusion?: OcclusionDefinition;\n}\n\nexport interface MaterialsDefinition {\n shading: Shading;\n bark: BarkMaterialDefinition;\n leaf: LeafMaterialDefinition;\n /** Structural Occlusion (a Material Feature, ADR 0008). Absent = off. */\n occlusion?: OcclusionDefinition;\n}\n\n/**\n * One keyframe of a track. In a Season Profile `t` is the Season (0 = first day of spring .. 1 = last\n * day of winter); in a Crown Shape curve it is the attach position on the parent branch (0 = base .. 1 = tip).\n */\nexport interface Keyframe<V> {\n t: number;\n value: V;\n}\n\n/**\n * How leaf colour, leaf coverage and blossom change across Season. Each track needs\n * at least one keyframe; keyframes are sorted by `t` (non-decreasing).\n */\nexport interface SeasonProfileDefinition {\n /** Leaf colour keyframes. */\n leafColor: Keyframe<HexColor>[];\n /** Leaf coverage keyframes (0 = bare .. 1 = full). */\n leafCoverage: Keyframe<number>[];\n /** Blossom amount keyframes (0 = none .. 1 = full bloom). */\n blossom: Keyframe<number>[];\n /** Blossom colour. */\n blossomColor: HexColor;\n /**\n * Fruit amount keyframes (0 = none .. 1 = all Fruit at full size); each Fruit shows while the amount\n * is above its own rank and swells with the amount. Absent = 1 all year. Only used with `fruit`.\n */\n fruit?: Keyframe<number>[];\n /** Fruit colour keyframes (ripening). Absent = a red (`DEFAULT_FRUIT_COLOR`) all year. Only used with `fruit`. */\n fruitColor?: Keyframe<HexColor>[];\n}\n\n/** Per-tree response to the scene-wide Wind. All 0 (stiff) .. 1 (very flexible). */\nexport interface WindResponseDefinition {\n /** Sway of the trunk. */\n trunk: number;\n /** Sway of the branches. */\n branches: number;\n /** Flutter of the leaves. */\n leaves: number;\n /** Sway speed multiplier (> 0; 1 = default). */\n frequency: number;\n}\n\n/** Seed ranges that are not tied to one tree part. All 0 (none) .. 1. */\nexport interface VariationDefinition {\n /** How much the Seed shifts bark and leaf colours. */\n color: number;\n /** How much the Seed shifts the timing of Growth (fraction of the 0..1 range). */\n growth: number;\n /** How much the Seed shifts the timing of Season (fraction of the 0..1 range). */\n season: number;\n}\n\ninterface SculptBase {\n /** The Seed the Sculpt was made on; every other Seed ignores it (ADR 0003). */\n seed: number;\n /** Branch path, e.g. \"0\" (trunk / first Stem), \"1\" (second Stem) or \"0.3.1\". */\n path: string;\n}\n/** Removes a branch and everything growing from it. */\nexport interface DeleteSculpt extends SculptBase {\n action: 'delete';\n}\n/** Rotates (Euler XYZ, radians) and scales a branch around its base. */\nexport interface MoveSculpt extends SculptBase {\n action: 'move';\n rotation: Vec3Tuple;\n /** Length scale (> 0). */\n scale: number;\n}\n/** Sets the leaf coverage (0..1) of a branch and everything growing from it. */\nexport interface LeavesSculpt extends SculptBase {\n action: 'leaves';\n coverage: number;\n}\n/** A hand edit made in the Tree Editor, tied to one Seed. */\nexport type Sculpt = DeleteSculpt | MoveSculpt | LeavesSculpt;\n\n/**\n * The full parameter set that describes how a tree is generated, independent of any Seed.\n */\nexport interface TreeDefinition {\n schemaVersion: typeof CURRENT_SCHEMA_VERSION;\n /** Optional human-readable name. */\n name: string;\n /** Id of the Species this Definition was made from by `Style.apply` (e.g. `'oak'`). Optional; never changes geometry. */\n species?: string;\n trunk: TrunkDefinition;\n /** Branching levels below the trunk (0..{@link MAX_BRANCH_LEVELS} entries). */\n branches: BranchLevelDefinition[];\n leaves: LeavesDefinition;\n /** Fruit on the outermost twigs; absent = none. */\n fruit?: FruitDefinition;\n /** Roots on every Stem; absent = none. */\n roots?: RootsDefinition;\n materials: MaterialsDefinition;\n season: SeasonProfileDefinition;\n wind: WindResponseDefinition;\n variation: VariationDefinition;\n sculpts: Sculpt[];\n}\n\n/**\n * Deep partial for Definition input. Objects may omit fields (they get defaults); arrays\n * replace the default array as a whole. Branch levels may be partial (missing fields come\n * from {@link DEFAULT_BRANCH_LEVEL}); keyframes and Sculpts must be complete.\n */\nexport type DeepPartial<T> = T extends (infer U)[]\n ? (U extends Keyframe<unknown> | Sculpt ? U : DeepPartial<U>)[]\n : T extends object\n ? { [K in keyof T]?: DeepPartial<T[K]> }\n : T;\n\n/**\n * What callers may pass: `schemaVersion` plus any subset of the fields; the rest is defaulted.\n * Older `schemaVersion`s are accepted and migrated.\n */\nexport type TreeDefinitionInput = { schemaVersion: number } & DeepPartial<Omit<TreeDefinition, 'schemaVersion'>>;\n","// Crown Shape helpers (ADR 0004): ready-made branch-level curves.\nimport type { Keyframe } from './types';\n\n/** The cone's shortest branches, as a fraction of the level's declared length. */\nconst MIN_CONE = 0.1;\n\n/**\n * The conifer cone as a Crown Shape length curve for a branch level starting at `start`: full length\n * at `start`, shrinking linearly to a tenth of it near the trunk tip, never below a tenth (the v2\n * generator's `max(0.1, (1 - t) / (1 - start))`). Written by the v2 -> v3 migration and used by every\n * Style's own conifer.\n */\nexport function coneCurve(start: number): Keyframe<number>[] {\n return [\n { t: start, value: 1 },\n // = 1 - MIN_CONE * (1 - start), written so round starts give round knees (0.18 -> 0.918).\n { t: 1 - MIN_CONE + MIN_CONE * start, value: MIN_CONE },\n { t: 1, value: MIN_CONE },\n ];\n}\n","import {\n CURRENT_SCHEMA_VERSION,\n type BranchLevelDefinition,\n type FruitDefinition,\n type GroundTintDefinition,\n type HexColor,\n type Keyframe,\n type OcclusionDefinition,\n type RootsDefinition,\n type TranslucencyDefinition,\n type TreeDefinition,\n} from './types';\n\n/** Defaults for one branching level; fills fields missing from a partial `branches[i]`. */\nexport const DEFAULT_BRANCH_LEVEL: BranchLevelDefinition = {\n count: 6,\n start: 0.35,\n end: 0.95,\n angle: 45,\n angleVariation: 0.2,\n spiral: 137.5,\n length: 0.5,\n lengthVariation: 0.2,\n radius: 0.6,\n taper: 0.3,\n sides: 6,\n sections: 5,\n bend: 0.1,\n gravity: 0.1,\n};\n\n/** Defaults for the fields of a `fruit` block (a Definition has no Fruit unless it has the block). */\nexport const DEFAULT_FRUIT: FruitDefinition = {\n type: 'round',\n count: 2,\n size: 0.12,\n sizeVariation: 0.2,\n hang: 0.7,\n};\n\n/** Defaults for the fields of a `roots` block (a Definition has no Roots unless it has the block). */\nexport const DEFAULT_ROOTS: RootsDefinition = {\n count: 5,\n length: 0.25,\n lengthVariation: 0.3,\n radius: 0.35,\n angle: 12,\n bend: 0.3,\n};\n\n/** Defaults for the fields of a `materials.bark.groundTint` block (no Ground Tint unless it has the block). */\nexport const DEFAULT_GROUND_TINT: GroundTintDefinition = {\n color: '#3f4a2a',\n height: 0.5,\n strength: 0.6,\n};\n\n/** Defaults for the fields of a partial `materials.leaf.translucency` block (no Leaf Translucency unless it has the block). */\nexport const DEFAULT_TRANSLUCENCY: TranslucencyDefinition = {\n strength: 0.5,\n edge: 0.5,\n ambient: 0.3,\n};\n\n/** Defaults for the fields of a partial `materials.occlusion` block (no Structural Occlusion unless it has the block). */\nexport const DEFAULT_OCCLUSION: OcclusionDefinition = {\n strength: 0.7,\n};\n\n/** Fruit amount when the Season Profile has no `fruit` track: all Fruit at full size all year. */\nexport const DEFAULT_FRUIT_AMOUNT: Keyframe<number>[] = [{ t: 0, value: 1 }];\n\n/** Fruit colour when the Season Profile has no `fruitColor` track. */\nexport const DEFAULT_FRUIT_COLOR: Keyframe<HexColor>[] = [{ t: 0, value: '#b8322a' }];\n\n/**\n * The documented defaults: a small broadleaf tree with two branching levels.\n * Anything a Definition leaves out is taken from here.\n */\nexport const DEFAULT_DEFINITION: TreeDefinition = {\n schemaVersion: CURRENT_SCHEMA_VERSION,\n name: '',\n trunk: {\n length: 4,\n radius: 0.25,\n taper: 0.4,\n sides: 8,\n sections: 8,\n lengthVariation: 0.15,\n bend: 0.08,\n },\n branches: [\n { ...DEFAULT_BRANCH_LEVEL },\n { ...DEFAULT_BRANCH_LEVEL, count: 4, start: 0.2, angle: 40, length: 0.45, sides: 4, sections: 3 },\n ],\n leaves: {\n count: 8,\n shape: 'card',\n size: 0.25,\n sizeVariation: 0.2,\n start: 0.3,\n angle: 40,\n },\n materials: {\n shading: 'standard',\n bark: { color: '#6b4a2b', roughness: 0.9, map: null, normalMap: null },\n leaf: { roughness: 0.7, map: null, alphaTest: 0.5 },\n },\n season: {\n // Deciduous: fresh green in spring, deep green in summer, autumn colours, bare in winter.\n leafColor: [\n { t: 0, value: '#8bc34a' },\n { t: 0.25, value: '#3e7d2b' },\n { t: 0.5, value: '#3e7d2b' },\n { t: 0.62, value: '#d8892b' },\n { t: 0.72, value: '#a0401f' },\n ],\n leafCoverage: [\n { t: 0, value: 0.3 },\n { t: 0.1, value: 1 },\n { t: 0.62, value: 1 },\n { t: 0.75, value: 0 },\n { t: 0.97, value: 0 },\n { t: 1, value: 0.3 },\n ],\n blossom: [{ t: 0, value: 0 }],\n blossomColor: '#f7c6d9',\n },\n wind: { trunk: 0.2, branches: 0.5, leaves: 0.8, frequency: 1 },\n variation: { color: 0.1, growth: 0.1, season: 0.05 },\n sculpts: [],\n};\n","/**\n * Schema migrations. `MIGRATIONS[n]` turns a raw (unvalidated) schemaVersion `n` object into\n * a raw schemaVersion `n + 1` object. Migrations run in order before defaults and validation,\n * so they only need to move/rename what changed; missing fields are defaulted afterwards.\n *\n * To change the format: bump CURRENT_SCHEMA_VERSION, add `MIGRATIONS[old]`, and add a\n * fixture in test/fixtures/definition-v<old>.json with a test.\n */\nimport { coneCurve } from './crown-shape';\nimport { DEFAULT_BRANCH_LEVEL, DEFAULT_DEFINITION } from './defaults';\n\ntype Raw = Record<string, unknown>;\n\nexport const MIGRATIONS: Record<number, (input: Raw) => Raw> = {\n /**\n * v1 -> v2: `bark` moved into `materials.bark`; branches, leaves, Season Profile, Wind,\n * variation and sculpts were added. A v1 tree was a bare trunk, so it keeps no branches\n * and no leaves (same tree as before).\n */\n 1: (input) => {\n const { bark, ...rest } = input;\n return {\n ...rest,\n schemaVersion: 2,\n branches: [],\n leaves: { count: 0 },\n ...(bark === undefined ? {} : { materials: { bark } }),\n };\n },\n /**\n * v2 -> v3: `form` is removed (ADR 0004). A conifer's cone becomes a Crown Shape length curve on\n * the first branch level (identical tree); a broadleaf just drops `form`. Unknown `form` values are\n * kept so validation reports them.\n */\n 2: (input) => {\n const { form, ...rest } = input;\n const out: Raw = { ...rest, schemaVersion: 3 };\n if (form !== undefined && form !== 'broadleaf' && form !== 'conifer') out.form = form;\n if (form !== 'conifer') return out;\n // A v2 Definition without `branches` grew the default levels; make them explicit to curve the first.\n const branches = Array.isArray(rest.branches) ? rest.branches : DEFAULT_DEFINITION.branches.map((b) => ({ ...b }));\n if (branches.length === 0) return out;\n const [first, ...deeper] = branches as unknown[];\n if (typeof first !== 'object' || first === null || Array.isArray(first)) return out; // validation reports it\n const level = first as Raw;\n const start = typeof level.start === 'number' ? level.start : DEFAULT_BRANCH_LEVEL.start;\n return { ...out, branches: [{ ...level, lengthProfile: coneCurve(start) }, ...deeper] };\n },\n};\n","import {\n DEFAULT_BRANCH_LEVEL,\n DEFAULT_DEFINITION,\n DEFAULT_FRUIT,\n DEFAULT_GROUND_TINT,\n DEFAULT_OCCLUSION,\n DEFAULT_ROOTS,\n DEFAULT_TRANSLUCENCY,\n} from './defaults';\nimport {\n BARK_TYPES,\n FRUIT_TYPES,\n CURRENT_SCHEMA_VERSION,\n LEAF_TYPES,\n MAX_BRANCH_LEVELS,\n type BarkMaterialDefinition,\n type BranchLevelDefinition,\n type DeleteSculpt,\n type FruitDefinition,\n type GroundTintDefinition,\n type LeafMaterialDefinition,\n type MaterialsDefinition,\n type OcclusionDefinition,\n type RootsDefinition,\n type TranslucencyDefinition,\n type SeasonProfileDefinition,\n type Keyframe,\n type LeavesDefinition,\n type LeavesSculpt,\n type MoveSculpt,\n type Sculpt,\n type TreeDefinition,\n type TrunkDefinition,\n} from './types';\n\n/** Thrown for an invalid Tree Definition; `field` is the path of the bad field, e.g. `branches[1].angle`. */\nexport class TreeDefinitionError extends Error {\n readonly field: string;\n constructor(field: string, message: string) {\n super(`Invalid Tree Definition: ${field} ${message}`);\n this.name = 'TreeDefinitionError';\n this.field = field;\n }\n}\n\n/**\n * A schema node: validates `value` at `path`, filling it from `fallback` (the default)\n * when it is undefined, and returns a fresh, complete value. Throws TreeDefinitionError.\n */\ntype Schema<T> = (value: unknown, fallback: T | undefined, path: string) => T;\n\nconst ROOT = '(root)';\nconst join = (path: string, key: string) => (path === ROOT ? key : `${path}.${key}`);\nconst show = (v: unknown) => (v === undefined ? 'undefined' : JSON.stringify(v));\n\nexport function isObject(v: unknown): v is Record<string, unknown> {\n return typeof v === 'object' && v !== null && !Array.isArray(v);\n}\n\n/** Leaf schema from a predicate; `undefined` takes the fallback, or is reported missing. */\nfunction leaf<T>(expected: string, ok: (v: unknown) => boolean): Schema<T> {\n return (value, fallback, path) => {\n const v = value === undefined ? fallback : value;\n if (v === undefined) throw new TreeDefinitionError(path, 'is missing');\n if (!ok(v)) throw new TreeDefinitionError(path, `must be ${expected}, got ${show(v)}`);\n return (Array.isArray(v) ? [...v] : v) as T;\n };\n}\n\nconst isNum = (v: unknown): v is number => typeof v === 'number' && Number.isFinite(v);\nconst range = (min: number, max: number) => leaf<number>(`a number from ${min} to ${max}`, (v) => isNum(v) && v >= min && v <= max);\nconst unit = range(0, 1);\nconst nonNegative = leaf<number>('a number >= 0', (v) => isNum(v) && v >= 0);\nconst positive = leaf<number>('a number > 0', (v) => isNum(v) && v > 0);\nconst finite = leaf<number>('a finite number', isNum);\nconst intAtLeast = (min: number) => leaf<number>(`an integer >= ${min}`, (v) => Number.isInteger(v) && (v as number) >= min);\nconst intRange = (min: number, max: number) =>\n leaf<number>(`an integer from ${min} to ${max}`, (v) => Number.isInteger(v) && (v as number) >= min && (v as number) <= max);\n/** Faces around a Fruit or a Root (its polygon detail). */\nconst partSides = intRange(3, 16);\nconst hexColor = leaf<string>('a colour like \"#6b4a2b\"', (v) => typeof v === 'string' && /^#[0-9a-f]{6}$/i.test(v));\nconst text = leaf<string>('a string', (v) => typeof v === 'string');\nconst url = leaf<string | null>('a URL string or null', (v) => v === null || (typeof v === 'string' && v.length > 0));\nconst vec3 = leaf<[number, number, number]>('[x, y, z] numbers', (v) => Array.isArray(v) && v.length === 3 && v.every(isNum));\nconst oneOf = <T extends string>(...values: T[]) =>\n leaf<T>(`one of ${values.map((x) => `\"${x}\"`).join(', ')}`, (v) => values.includes(v as T));\nconst literal = <T>(expected: T) => leaf<T>(String(expected), (v) => v === expected);\n\n/** An optional field: absent (undefined) stays absent, anything else must match `schema`. */\nfunction optional<T>(schema: Schema<T>): Schema<T | undefined> {\n return (value, fallback, path) => (value === undefined && fallback === undefined ? undefined : schema(value, fallback, path));\n}\n\n/** An optional block: absent stays absent; a given (possibly partial) block is filled from `defaults`. */\nfunction optionalBlock<T>(schema: Schema<T>, defaults: T): Schema<T | undefined> {\n return (value, fallback, path) => (value === undefined && fallback === undefined ? undefined : schema(value, fallback ?? defaults, path));\n}\n\n/** Object with exactly these fields; unknown fields are rejected (catches typos). */\nfunction obj<T>(fields: { [K in keyof T]-?: Schema<T[K]> }): Schema<T> {\n return (value, fallback, path) => {\n if (value === undefined && fallback === undefined) throw new TreeDefinitionError(path, 'is missing');\n const given = value === undefined ? {} : value;\n if (!isObject(given)) throw new TreeDefinitionError(path, `must be an object, got ${show(given)}`);\n for (const key of Object.keys(given)) {\n if (!(key in fields)) throw new TreeDefinitionError(join(path, key), 'is not a known field');\n }\n const out: Record<string, unknown> = {};\n for (const key of Object.keys(fields) as (keyof T & string)[]) {\n const field = fields[key](given[key], fallback?.[key], join(path, key));\n // Optional fields (see `optional`) that are absent stay absent.\n if (field !== undefined) out[key] = field;\n }\n return out as T;\n };\n}\n\n/** Array; a missing array takes the fallback array, each item is filled from `itemFallback`. */\nfunction arr<T>(item: Schema<T>, opts: { min?: number; max?: number; itemFallback?: T } = {}): Schema<T[]> {\n const { min = 0, max = Infinity, itemFallback } = opts;\n return (value, fallback, path) => {\n const v = value === undefined ? fallback : value;\n if (v === undefined) throw new TreeDefinitionError(path, 'is missing');\n if (!Array.isArray(v)) throw new TreeDefinitionError(path, `must be an array, got ${show(v)}`);\n if (v.length < min) throw new TreeDefinitionError(path, `must have at least ${min} entries`);\n if (v.length > max) throw new TreeDefinitionError(path, `must have at most ${max} entries`);\n return v.map((x, i) => item(x, itemFallback, `${path}[${i}]`));\n };\n}\n\n/** Adds a cross-field check; `check` returns [field, problem] or null. */\nfunction refine<T>(schema: Schema<T>, check: (v: T) => [string, string] | null): Schema<T> {\n return (value, fallback, path) => {\n const v = schema(value, fallback, path);\n const problem = check(v);\n if (problem) throw new TreeDefinitionError(join(path, problem[0]), problem[1]);\n return v;\n };\n}\n\n/** Union discriminated by `key`. */\nfunction tagged<T>(key: string, variants: Record<string, Schema<T>>): Schema<T> {\n const names = Object.keys(variants);\n return (value, fallback, path) => {\n if (!isObject(value)) throw new TreeDefinitionError(path, `must be an object, got ${show(value)}`);\n const variant = variants[value[key] as string];\n if (!variant) {\n throw new TreeDefinitionError(join(path, key), `must be one of ${names.map((n) => `\"${n}\"`).join(', ')}, got ${show(value[key])}`);\n }\n return variant(value, fallback, path);\n };\n}\n\n/** Keyframe track: at least one key, `t` in 0..1 and non-decreasing. */\nfunction track<V>(value: Schema<V>): Schema<Keyframe<V>[]> {\n const keys = arr(obj<Keyframe<V>>({ t: unit, value }), { min: 1 });\n return (v, fallback, path) => {\n const out = keys(v, fallback, path);\n for (let i = 1; i < out.length; i++) {\n if (out[i]!.t < out[i - 1]!.t) {\n throw new TreeDefinitionError(`${path}[${i}].t`, `must be >= the previous keyframe's t (${out[i - 1]!.t}), got ${out[i]!.t}`);\n }\n }\n return out;\n };\n}\n\nconst branchLevel = refine(\n obj<BranchLevelDefinition>({\n count: intAtLeast(0),\n start: unit,\n end: unit,\n angle: range(0, 180),\n angleVariation: unit,\n spiral: range(0, 360),\n length: positive,\n lengthVariation: unit,\n radius: unit,\n taper: unit,\n sides: intAtLeast(3),\n sections: intAtLeast(1),\n bend: unit,\n gravity: range(-1, 1),\n lengthProfile: optional(track(nonNegative)),\n angleProfile: optional(track(nonNegative)),\n }),\n (b) => (b.end < b.start ? ['end', `must be >= start (${b.start}), got ${b.end}`] : null),\n);\n\nconst branchPath = leaf<string>('a branch path like \"0\", \"1\" or \"0.3.1\"', (v) => typeof v === 'string' && /^\\d+(\\.\\d+)*$/.test(v));\nconst sculpt = tagged<Sculpt>('action', {\n delete: obj<DeleteSculpt>({ action: literal('delete'), seed: finite, path: branchPath }) as Schema<Sculpt>,\n move: obj<MoveSculpt>({ action: literal('move'), seed: finite, path: branchPath, rotation: vec3, scale: positive }) as Schema<Sculpt>,\n leaves: obj<LeavesSculpt>({ action: literal('leaves'), seed: finite, path: branchPath, coverage: unit }) as Schema<Sculpt>,\n});\n\n/** The whole Tree Definition schema (current version). Mirrors the interfaces in types.ts. */\nconst treeDefinition = obj<TreeDefinition>({\n schemaVersion: literal(CURRENT_SCHEMA_VERSION),\n name: text,\n species: optional(text),\n trunk: obj<TrunkDefinition>({\n length: positive,\n radius: positive,\n taper: unit,\n sides: intAtLeast(3),\n sections: intAtLeast(1),\n lengthVariation: unit,\n bend: unit,\n stems: optional(intAtLeast(1)),\n spread: optional(range(0, 90)),\n gravity: optional(range(-1, 1)),\n flare: optional(unit),\n flareSections: optional(intAtLeast(1)),\n }),\n branches: arr(branchLevel, { max: MAX_BRANCH_LEVELS, itemFallback: DEFAULT_BRANCH_LEVEL }),\n leaves: obj<LeavesDefinition>({\n type: optional(oneOf(...LEAF_TYPES)),\n count: intAtLeast(0),\n shape: oneOf('card', 'clump', 'needle', 'puff'),\n size: positive,\n sizeVariation: unit,\n start: unit,\n angle: range(0, 180),\n }),\n fruit: optionalBlock<FruitDefinition>(\n obj<FruitDefinition>({\n type: oneOf(...FRUIT_TYPES),\n count: nonNegative,\n size: positive,\n sizeVariation: unit,\n hang: unit,\n sides: optional(partSides),\n }),\n DEFAULT_FRUIT,\n ),\n roots: optionalBlock<RootsDefinition>(\n obj<RootsDefinition>({\n count: intRange(0, 12),\n length: unit,\n lengthVariation: unit,\n radius: unit,\n angle: range(0, 60),\n bend: unit,\n sides: optional(partSides),\n sections: optional(intAtLeast(1)),\n }),\n DEFAULT_ROOTS,\n ),\n materials: obj<MaterialsDefinition>({\n shading: oneOf('standard', 'flat', 'toon'),\n bark: obj<BarkMaterialDefinition>({\n type: optional(oneOf(...BARK_TYPES)),\n color: hexColor,\n roughness: unit,\n map: url,\n normalMap: url,\n groundTint: optionalBlock<GroundTintDefinition>(\n obj<GroundTintDefinition>({ color: hexColor, height: positive, strength: unit }),\n DEFAULT_GROUND_TINT,\n ),\n }),\n leaf: obj<LeafMaterialDefinition>({\n roughness: unit,\n map: url,\n alphaTest: unit,\n // Material Features (ADR 0008): optional, absent = off.\n crownNormals: optional(unit),\n translucency: optionalBlock<TranslucencyDefinition>(\n obj<TranslucencyDefinition>({ strength: unit, edge: unit, ambient: unit }),\n DEFAULT_TRANSLUCENCY,\n ),\n }),\n occlusion: optionalBlock<OcclusionDefinition>(obj<OcclusionDefinition>({ strength: unit }), DEFAULT_OCCLUSION),\n }),\n season: obj<SeasonProfileDefinition>({\n leafColor: track(hexColor),\n leafCoverage: track(unit),\n blossom: track(unit),\n blossomColor: hexColor,\n fruit: optional(track(unit)),\n fruitColor: optional(track(hexColor)),\n }),\n wind: obj({ trunk: unit, branches: unit, leaves: unit, frequency: positive }),\n variation: obj({ color: unit, growth: unit, season: unit }),\n sculpts: arr(sculpt),\n});\n\n/**\n * Validates a raw current-version Definition and fills every missing field from\n * {@link DEFAULT_DEFINITION}. Returns a fresh object (never aliases input or defaults).\n */\nexport function validateDefinition(raw: Record<string, unknown>): TreeDefinition {\n return treeDefinition(raw, DEFAULT_DEFINITION, ROOT);\n}\n","import { MIGRATIONS } from './migrations';\nimport { isObject, TreeDefinitionError, validateDefinition } from './schema';\nimport { CURRENT_SCHEMA_VERSION, type DeepPartial, type TreeDefinition, type TreeDefinitionInput } from './types';\n\nexport { TreeDefinitionError } from './schema';\n\n/**\n * Turns untrusted input into a complete, valid Tree Definition:\n * - `input` is a Definition object (e.g. parsed JSON) or a JSON string;\n * - older `schemaVersion`s are migrated to {@link CURRENT_SCHEMA_VERSION};\n * - missing fields are filled from {@link DEFAULT_DEFINITION} (missing fields of a\n * `branches[i]` entry from {@link DEFAULT_BRANCH_LEVEL});\n * - every field is validated; unknown fields are rejected.\n * Throws {@link TreeDefinitionError} naming the first bad field (`field`, e.g. `branches[1].angle`).\n * Never mutates `input`.\n */\nexport function parseDefinition(input: unknown): TreeDefinition {\n let raw = input;\n if (typeof raw === 'string') {\n try {\n raw = JSON.parse(raw);\n } catch (e) {\n throw new TreeDefinitionError('(root)', `is not valid JSON: ${(e as Error).message}`);\n }\n }\n if (!isObject(raw)) throw new TreeDefinitionError('(root)', 'must be an object');\n const version = raw.schemaVersion;\n if (version === undefined) throw new TreeDefinitionError('schemaVersion', 'is missing');\n if (!Number.isInteger(version) || (version as number) < 1) {\n throw new TreeDefinitionError('schemaVersion', `must be an integer >= 1, got ${JSON.stringify(version)}`);\n }\n if ((version as number) > CURRENT_SCHEMA_VERSION) {\n throw new TreeDefinitionError(\n 'schemaVersion',\n `is ${version}, newer than this version of @casmo/tree.js supports (${CURRENT_SCHEMA_VERSION}); upgrade the library`,\n );\n }\n for (let v = version as number; v < CURRENT_SCHEMA_VERSION; v++) raw = MIGRATIONS[v]!(raw as Record<string, unknown>);\n return validateDefinition(raw as Record<string, unknown>);\n}\n\n/** Changes to apply on top of a Definition: any subset of its fields (arrays replace as a whole). */\nexport type DefinitionPatch = DeepPartial<Omit<TreeDefinition, 'schemaVersion'>>;\n\n/**\n * Starts from a Definition (e.g. a built-in Style) and changes a few parameters:\n * objects are merged deeply, arrays and values replace. Returns a new, validated Definition.\n *\n * ```ts\n * const tall = extendDefinition(broadleaf, { trunk: { length: 7 }, wind: { leaves: 1 } });\n * ```\n */\nexport function extendDefinition(base: TreeDefinition | TreeDefinitionInput, patch: DefinitionPatch): TreeDefinition {\n const parsed = parseDefinition(base);\n if (!isObject(patch)) throw new TreeDefinitionError('(root)', 'patch must be an object');\n return parseDefinition({ ...merge(parsed as unknown as Record<string, unknown>, patch), schemaVersion: CURRENT_SCHEMA_VERSION });\n}\n\nfunction merge(base: Record<string, unknown>, patch: Record<string, unknown>): Record<string, unknown> {\n const out: Record<string, unknown> = { ...base };\n for (const [key, value] of Object.entries(patch)) {\n if (value === undefined) continue;\n out[key] = isObject(value) && isObject(base[key]) ? merge(base[key], value) : value;\n }\n return out;\n}\n\n/**\n * Fetches a Tree Definition JSON file (e.g. a Tree Editor export) and parses it with\n * {@link parseDefinition}. Rejects with an Error for an HTTP error, or a TreeDefinitionError.\n */\nexport async function fetchDefinition(url: string | URL, init?: RequestInit): Promise<TreeDefinition> {\n const response = await fetch(url, init);\n if (!response.ok) throw new Error(`Could not load Tree Definition from ${String(url)}: HTTP ${response.status}`);\n return parseDefinition(await response.text());\n}\n","// Suggested Material Features per Style and the helper that opts a Definition in (ADR 0008).\n// Built-in Styles and Species never set Material Features: the app applies them explicitly.\nimport { parseDefinition } from '../definition/parse';\nimport type { MaterialFeatures, TreeDefinition, TreeDefinitionInput } from '../definition/types';\nimport type { StyleName } from './names';\n\n/**\n * Suggested Material Features for each built-in Style (like `SUGGESTED_TREE_EFFECTS`). Nothing uses\n * them by default; pass one to {@link withMaterialFeatures} to opt a Definition in.\n *\n * Tuned against the e2e screenshots (e2e/material-features.spec.ts). Structural Occlusion only darkens\n * ambient light, so it is set high; translucency stays low enough that a crown against the sun keeps its shape.\n */\nexport const SUGGESTED_MATERIAL_FEATURES: Record<StyleName, MaterialFeatures> = {\n // Facets stay visible (half-way crown normals); no translucency, which would soften the flat look.\n 'low-poly': {\n crownNormals: 0.5,\n occlusion: { strength: 0.8 },\n },\n // The crown lit as one soft shape, with a glow mostly at its thin edge against the sun.\n stylized: {\n crownNormals: 1,\n translucency: { strength: 0.3, edge: 0.8, ambient: 0.2 },\n occlusion: { strength: 0.9 },\n },\n // Some per-card detail stays; a natural glow, strongest at the thin edge of the crown.\n realistic: {\n crownNormals: 0.6,\n translucency: { strength: 0.45, edge: 0.7, ambient: 0.25 },\n occlusion: { strength: 0.9 },\n },\n};\n\n/**\n * The Material Features a Tree Definition has (`materials.leaf.crownNormals`, `materials.leaf.translucency`,\n * `materials.occlusion`), in the shape {@link withMaterialFeatures} takes. A feature that is absent is left\n * out; the values are the Definition's own (not copies).\n */\nexport function materialFeaturesOf(definition: TreeDefinition): MaterialFeatures {\n const { crownNormals, translucency } = definition.materials.leaf;\n const { occlusion } = definition.materials;\n return {\n ...(crownNormals === undefined ? {} : { crownNormals }),\n ...(translucency === undefined ? {} : { translucency }),\n ...(occlusion === undefined ? {} : { occlusion }),\n };\n}\n\n/**\n * Returns a new Tree Definition whose Material Features are exactly `features`: each feature given is\n * set, each feature left out is switched off (`{}` switches them all off). Everything else is kept. The\n * input is not changed. Throws a TreeDefinitionError for an out-of-range value.\n *\n * ```ts\n * const tree = createTree(withMaterialFeatures(stylized.broadleaf, SUGGESTED_MATERIAL_FEATURES.stylized));\n * ```\n */\nexport function withMaterialFeatures(definition: TreeDefinition | TreeDefinitionInput, features: MaterialFeatures): TreeDefinition {\n const parsed = parseDefinition(definition);\n // parseDefinition returns fresh objects, so the copies can drop the old features.\n const leaf = { ...parsed.materials.leaf };\n delete leaf.crownNormals;\n delete leaf.translucency;\n const materials = { ...parsed.materials };\n delete materials.occlusion;\n const { crownNormals, translucency, occlusion } = features;\n return parseDefinition({\n ...parsed,\n materials: {\n ...materials,\n leaf: {\n ...leaf,\n ...(crownNormals === undefined ? {} : { crownNormals }),\n ...(translucency === undefined ? {} : { translucency: { ...translucency } }),\n },\n ...(occlusion === undefined ? {} : { occlusion: { ...occlusion } }),\n },\n });\n}\n","// The built-in Styles: their names, display labels and shading. Kept apart from the loaders\n// (registry.ts) so Style.apply, the editor and the scripts can use them without pulling in a Style.\nimport type { Shading } from '../definition/types';\n\n/** Every built-in Style: its display label and the shading its Definitions use (one shading per Style). */\nconst STYLES = {\n 'low-poly': { label: 'Low-poly', shading: 'flat' },\n stylized: { label: 'Stylized', shading: 'toon' },\n realistic: { label: 'Realistic', shading: 'standard' },\n} as const satisfies Record<string, { label: string; shading: Shading }>;\n\n/** Name of a built-in Style, e.g. 'low-poly'. */\nexport type StyleName = keyof typeof STYLES;\n\n/** Names of all built-in Styles. */\nexport const STYLE_NAMES = Object.keys(STYLES) as StyleName[];\n\n/** Display label of a built-in Style, e.g. 'Low-poly'. */\nexport function styleLabel(name: StyleName): string {\n return STYLES[name].label;\n}\n\n/** The shading a built-in Style draws with. */\nexport function styleShading(name: StyleName): Shading {\n return STYLES[name].shading;\n}\n\n/** The built-in Style a Definition was drawn in, recognised by its `materials.shading`. */\nexport function styleOfShading(shading: Shading): StyleName {\n return STYLE_NAMES.find((name) => STYLES[name].shading === shading)!;\n}\n"],"mappings":";;;;;;;;;;;;;;AAcA,IAAa,yBAAyB;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AAGA,SAAgB,aAAa,MAA0B;CACrD,OAAO,OAAO,KAAK,CAAC;AACtB;;AAGA,SAAgB,eAAe,SAA6B;CAC1D,OAAO,YAAY,MAAM,SAAS,OAAO,KAAK,CAAC,YAAY,OAAO;AACpE"}
@@ -1,6 +1,7 @@
1
1
  import { type Ref } from 'react';
2
2
  import type { ThreeElements } from '@react-three/fiber';
3
3
  import type { TreeDefinition, TreeDefinitionInput, TreeForm } from '../definition';
4
+ import type { SpeciesDefinition } from '../species/types';
4
5
  import type { TreeStyle } from '../styles/types';
5
6
  import type { StyleName } from '../styles/registry';
6
7
  import { type Tree as TreeObject } from '../tree';
@@ -16,6 +17,8 @@ export interface TreeProps extends GroupProps {
16
17
  style?: TreeStyle | StyleName;
17
18
  /** Which of the Style's Forms to grow. Default 'broadleaf'. */
18
19
  form?: TreeForm;
20
+ /** A Species (e.g. `oak` from `@casmo/tree.js/species`) to grow in `style`: `style.apply(species)` instead of a Form. */
21
+ species?: SpeciesDefinition;
19
22
  /** Picks one individual tree within the Definition's ranges. Default 0. Changing it regenerates the tree. */
20
23
  seed?: number;
21
24
  /** Growth 0 (sapling) .. 1 (default). Only updates a uniform. */
@@ -33,9 +36,9 @@ export interface TreeProps extends GroupProps {
33
36
  }
34
37
  /**
35
38
  * A procedural tree. Growth, Season, Wind and shadow props only update the existing tree; a new
36
- * `seed`, `definition` (by value) or `style`/`form` regenerates it. The tree is disposed
39
+ * `seed`, `definition` (by value) or `style`/`form`/`species` regenerates it. The tree is disposed
37
40
  * of on unmount.
38
41
  */
39
- export declare function Tree({ definition, style, form, seed, growth, season, wind, castShadow, receiveShadow, ref, ...groupProps }: TreeProps): import("react").JSX.Element;
42
+ export declare function Tree({ definition, style, form, species, seed, growth, season, wind, castShadow, receiveShadow, ref, ...groupProps }: TreeProps): import("react").JSX.Element;
40
43
  export {};
41
44
  //# sourceMappingURL=Tree.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Tree.d.ts","sourceRoot":"","sources":["../../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AAI,CAAC,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,qDAAqD;IACrD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,+FAA+F;IAC/F,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,oDAAoD;IACpD,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,uDAAuD;IACvD,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,6DAA6D;IAC7D,GAAG,CAAC,EAAE,GAAG,CAAC,UAAU,CAAC,CAAC;CACvB;AAKD;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,EACnB,UAAU,EACV,KAAK,EACL,IAAkB,EAClB,OAAO,EACP,IAAQ,EACR,MAAU,EACV,MAAU,EACV,IAAI,EACJ,UAAiB,EACjB,aAAoB,EACpB,GAAG,EACH,GAAG,UAAU,EACd,EAAE,SAAS,+BA4CX"}
package/dist/react.js CHANGED
@@ -1,4 +1,4 @@
1
- import { D as clampGrowth, H as wrapSeason, a as forestTreeKey, c as createTree, f as sceneWind, s as loadStyle, t as createForest } from "./forest-OX9WvAwh.js";
1
+ import { O as clampGrowth, Y as wrapSeason, a as forestTreeKey, d as sceneWind, o as loadStyle, s as createTree, t as createForest } from "./forest-ChEaWJrf.js";
2
2
  import { use, useEffect, useLayoutEffect, useMemo, useState } from "react";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
  // src/react/useTreeStyle.ts
@@ -33,12 +33,12 @@ function preloadTreeStyle(name) {
33
33
  var disposed$1 = /* @__PURE__ */ new WeakSet();
34
34
  /**
35
35
  * A procedural tree. Growth, Season, Wind and shadow props only update the existing tree; a new
36
- * `seed`, `definition` (by value) or `style`/`form` regenerates it. The tree is disposed
36
+ * `seed`, `definition` (by value) or `style`/`form`/`species` regenerates it. The tree is disposed
37
37
  * of on unmount.
38
38
  */
39
- function Tree({ definition, style, form = "broadleaf", seed = 0, growth = 1, season = 0, wind, castShadow = true, receiveShadow = true, ref, ...groupProps }) {
39
+ function Tree({ definition, style, form = "broadleaf", species, seed = 0, growth = 1, season = 0, wind, castShadow = true, receiveShadow = true, ref, ...groupProps }) {
40
40
  const styleObject = definition === void 0 && typeof style === "string" ? useTreeStyle(style) : style;
41
- const source = definition ?? (typeof styleObject === "object" ? styleObject[form] : void 0);
41
+ const source = definition ?? (typeof styleObject === "object" ? species ? styleObject.apply(species) : styleObject[form] : void 0);
42
42
  if (source === void 0) throw new Error("<Tree> needs a `definition` or a `style`.");
43
43
  const key = JSON.stringify(source);
44
44
  const [generation, setGeneration] = useState(0);
@@ -69,7 +69,11 @@ function Tree({ definition, style, form = "broadleaf", seed = 0, growth = 1, sea
69
69
  tree.season = season;
70
70
  }, [tree, season]);
71
71
  useLayoutEffect(() => {
72
- for (const mesh of [tree.wood, tree.leaves]) {
72
+ for (const mesh of [
73
+ tree.wood,
74
+ tree.leaves,
75
+ tree.fruit
76
+ ]) {
73
77
  mesh.castShadow = castShadow;
74
78
  mesh.receiveShadow = receiveShadow;
75
79
  }
@@ -218,7 +222,7 @@ function Forest({ definition, style, form = "broadleaf", variants = 4, seed = 0,
218
222
  season
219
223
  ]);
220
224
  useLayoutEffect(() => {
221
- for (const variant of forest.variants) for (const mesh of [variant.wood, variant.leaves]) {
225
+ for (const variant of forest.variants) for (const mesh of variant.meshes) {
222
226
  mesh.castShadow = castShadow;
223
227
  mesh.receiveShadow = receiveShadow;
224
228
  }
package/dist/react.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"react.js","names":["disposed"],"sources":["../src/react/useTreeStyle.ts","../src/react/Tree.tsx","../src/react/Wind.tsx","../src/react/Forest.tsx"],"sourcesContent":["import { use } from 'react';\nimport { loadStyle, type StyleName } from '../styles/registry';\nimport type { TreeStyle } from '../styles/types';\n\n// One promise per Style name, so every render (and every component) suspends on the same load.\nconst cache = new Map<string, Promise<TreeStyle>>();\n\nfunction styleResource(name: StyleName): Promise<TreeStyle> {\n let promise = cache.get(name);\n if (!promise) {\n promise = loadStyle(name);\n cache.set(name, promise);\n // A failed load is not cached, so a later render can retry (the error still reaches the error boundary).\n promise.catch(() => cache.delete(name));\n }\n return promise;\n}\n\n/**\n * Loads a built-in Style with a dynamic import and returns it. Suspends (React Suspense) while\n * it downloads, so wrap the component in `<Suspense>`. Unknown names throw to the nearest error boundary.\n *\n * ```tsx\n * const lowPoly = useTreeStyle('low-poly');\n * return <Tree style={lowPoly} form=\"conifer\" seed={7} />;\n * ```\n */\nexport function useTreeStyle(name: StyleName): TreeStyle {\n return use(styleResource(name));\n}\n\n/** Starts loading a Style ahead of time (e.g. on hover), without suspending. */\nexport function preloadTreeStyle(name: StyleName): void {\n void styleResource(name).catch(() => {});\n}\n","import { useEffect, useLayoutEffect, useMemo, useState, type Ref } from 'react';\nimport type { ThreeElements } from '@react-three/fiber';\nimport type { TreeDefinition, TreeDefinitionInput, TreeForm } from '../definition';\nimport type { TreeStyle } from '../styles/types';\nimport type { StyleName } from '../styles/registry';\nimport { createTree, type Tree as TreeObject } from '../tree';\nimport { sceneWind, type Wind as WindObject } from '../wind';\nimport { useTreeStyle } from './useTreeStyle';\n\ntype GroupProps = Omit<ThreeElements['group'], 'args' | 'object' | 'children' | 'ref' | 'castShadow' | 'receiveShadow' | 'dispose'>;\n\nexport interface TreeProps extends GroupProps {\n /** The Tree Definition to grow (plain object or parsed JSON). Takes precedence over `style`. */\n definition?: TreeDefinitionInput | TreeDefinition;\n /**\n * A Style: its Definition for `form` is grown. Pass the object from {@link useTreeStyle}, or a\n * built-in Style name, which is loaded on demand (the component suspends until it is there).\n */\n style?: TreeStyle | StyleName;\n /** Which of the Style's Forms to grow. Default 'broadleaf'. */\n form?: TreeForm;\n /** Picks one individual tree within the Definition's ranges. Default 0. Changing it regenerates the tree. */\n seed?: number;\n /** Growth 0 (sapling) .. 1 (default). Only updates a uniform. */\n growth?: number;\n /** Season 0 .. 1 (wraps). Only updates a uniform. */\n season?: number;\n /** The Wind this tree sways with. Default: the scene-wide `sceneWind` (what `<Wind>` sets). */\n wind?: WindObject;\n /** Whether the tree casts shadows. Default true. */\n castShadow?: boolean;\n /** Whether the tree receives shadows. Default true. */\n receiveShadow?: boolean;\n /** Receives the tree.js `Tree` object (a three.js Group). */\n ref?: Ref<TreeObject>;\n}\n\n/** Trees this module has disposed of (React StrictMode re-runs effects on the same memoised tree). */\nconst disposed = new WeakSet<TreeObject>();\n\n/**\n * A procedural tree. Growth, Season, Wind and shadow props only update the existing tree; a new\n * `seed`, `definition` (by value) or `style`/`form` regenerates it. The tree is disposed\n * of on unmount.\n */\nexport function Tree({\n definition,\n style,\n form = 'broadleaf',\n seed = 0,\n growth = 1,\n season = 0,\n wind,\n castShadow = true,\n receiveShadow = true,\n ref,\n ...groupProps\n}: TreeProps) {\n // `use()` (behind useTreeStyle) may be called conditionally, so a style name suspends right here.\n const styleObject = definition === undefined && typeof style === 'string' ? useTreeStyle(style) : style;\n const source = definition ?? (typeof styleObject === 'object' ? styleObject[form] : undefined);\n if (source === undefined) throw new Error('<Tree> needs a `definition` or a `style`.');\n // Compare Definitions by value, so an inline object literal does not regenerate on every render.\n const key = JSON.stringify(source);\n\n // Bumped when StrictMode disposed the memoised tree, to grow a fresh one.\n const [generation, setGeneration] = useState(0);\n const tree = useMemo(\n () => createTree(JSON.parse(key) as TreeDefinitionInput, { seed, wind, growth, season }),\n // growth/season/wind are only the starting values; the effects below keep them in sync.\n [key, seed, generation],\n );\n\n useEffect(() => {\n if (disposed.has(tree)) setGeneration((g) => g + 1);\n return () => {\n disposed.add(tree);\n tree.dispose();\n };\n }, [tree]);\n\n useLayoutEffect(() => {\n tree.wind = wind ?? sceneWind;\n }, [tree, wind]);\n\n useLayoutEffect(() => {\n tree.growth = growth;\n }, [tree, growth]);\n\n useLayoutEffect(() => {\n tree.season = season;\n }, [tree, season]);\n\n useLayoutEffect(() => {\n for (const mesh of [tree.wood, tree.leaves]) {\n mesh.castShadow = castShadow;\n mesh.receiveShadow = receiveShadow;\n }\n }, [tree, castShadow, receiveShadow]);\n\n return <primitive object={tree} ref={ref} {...groupProps} />;\n}\n","import { useLayoutEffect } from 'react';\nimport { sceneWind, type Wind as WindObject, type WindDirection } from '../wind';\n\nexport interface WindProps {\n /** World-space direction the wind blows towards (any non-zero length). Unset: leave as is (default +X). */\n direction?: WindDirection;\n /** 0 = calm, 1 = strong wind, more for storms. Unset: leave as is (default 0). */\n strength?: number;\n /** Pins the Wind clock to this many seconds (pause, screenshots). Unset: the renderer clock. */\n time?: number | null;\n /** The Wind to drive. Default: the scene-wide `sceneWind` every `<Tree>` sways with. */\n wind?: WindObject;\n}\n\n/**\n * Declares the Wind. Renders nothing; it writes the Wind's uniforms (no recompile), and puts back the\n * direction, strength and clock it found when it unmounts.\n */\nexport function Wind({ direction, strength, time = null, wind = sceneWind }: WindProps): null {\n // Depend on the components, so a new array literal with the same values does nothing.\n const [x, y, z] = direction === undefined ? [] : Array.isArray(direction) ? direction : (direction as { toArray(): number[] }).toArray();\n\n useLayoutEffect(() => {\n const previous = { direction: wind.direction, strength: wind.strength, time: wind.time };\n return () => {\n wind.set(previous);\n wind.time = previous.time;\n };\n }, [wind]);\n\n useLayoutEffect(() => {\n if (x !== undefined) wind.direction = [x, y!, z!];\n }, [wind, x, y, z]);\n\n useLayoutEffect(() => {\n if (strength !== undefined) wind.strength = strength;\n }, [wind, strength]);\n\n useLayoutEffect(() => {\n wind.time = time;\n }, [wind, time]);\n\n return null;\n}\n","import { useEffect, useLayoutEffect, useMemo, useState, type Ref } from 'react';\nimport type { ThreeElements } from '@react-three/fiber';\nimport type { TreeDefinition, TreeDefinitionInput, TreeForm } from '../definition';\nimport type { TreeStyle } from '../styles/types';\nimport type { StyleName } from '../styles/registry';\nimport { createForest, type Forest as ForestObject } from '../forest';\nimport { forestTreeKey, type ForestPlacement } from '../forest/placement';\nimport { clampGrowth } from '../growth/evaluate';\nimport { wrapSeason } from '../season/profile';\nimport { sceneWind, type Wind as WindObject } from '../wind';\nimport { useTreeStyle } from './useTreeStyle';\n\ntype GroupProps = Omit<ThreeElements['group'], 'args' | 'object' | 'children' | 'ref' | 'castShadow' | 'receiveShadow' | 'dispose'>;\n\n/** Where one tree of a `<Forest>` stands, optionally with its own Growth and Season. */\nexport interface ForestTreePlacement extends ForestPlacement {\n /** This tree's Growth, 0..1. Default: the forest's `growth`. */\n growth?: number;\n /** This tree's Season, 0..1 (wraps). Default: the forest's `season`. */\n season?: number;\n}\n\nexport interface ForestProps extends GroupProps {\n /** The Tree Definition every tree is grown from (plain object or parsed JSON). Takes precedence over `style`. */\n definition?: TreeDefinitionInput | TreeDefinition;\n /** A Style (object from {@link useTreeStyle}, or a built-in Style name, loaded on demand: suspends). */\n style?: TreeStyle | StyleName;\n /** Which of the Style's Forms to grow. Default 'broadleaf'. */\n form?: TreeForm;\n /** How many Variants (distinct trees, each drawn instanced). Default 4. Changing it rebuilds the forest. */\n variants?: number;\n /** The forest seed. Default 0. Changing it rebuilds the forest. */\n seed?: number;\n /**\n * The trees. Trees are matched by key (their `id`, or their position without one), so adding or\n * removing placements only plants or cuts those trees; the others keep their look and instance data.\n */\n placements: readonly ForestTreePlacement[];\n /** Growth of every tree without its own `growth`, 0..1. Default 1. Only rewrites instance data. */\n growth?: number;\n /** Season of every tree without its own `season`, 0..1 (wraps). Default 0. Only rewrites instance data. */\n season?: number;\n /** The Wind the forest sways with. Default: the scene-wide `sceneWind` (what `<Wind>` sets). */\n wind?: WindObject;\n /** Whether the trees cast shadows. Default true. */\n castShadow?: boolean;\n /** Whether the trees receive shadows. Default true. */\n receiveShadow?: boolean;\n /** Receives the tree.js `Forest` object (a three.js Group). */\n ref?: Ref<ForestObject>;\n}\n\n/** Forests this module has disposed of (React StrictMode re-runs effects on the same memoised forest). */\nconst disposed = new WeakSet<ForestObject>();\n\n/** The placement without the React-only per-tree state. */\nfunction placementOf(p: ForestTreePlacement): ForestPlacement {\n const placement = { ...p };\n delete placement.growth;\n delete placement.season;\n return placement;\n}\n\n/** What makes a tree stand where it does; a change re-plants the tree. */\nfunction pose(p: ForestPlacement): string {\n const v = p.position;\n const position = Array.isArray(v) ? [v[0], v[1], v[2]] : [(v as { x: number }).x, (v as { y: number }).y, (v as { z: number }).z];\n return JSON.stringify([position, p.rotation ?? 0, p.scale ?? 1]);\n}\n\n/**\n * Brings `forest` in line with `placements`: cuts trees that are no longer placed, plants new ones,\n * re-plants moved ones, and writes Growth/Season only where they differ. Untouched trees are not rewritten.\n */\nfunction syncForest(forest: ForestObject, placements: readonly ForestTreePlacement[], growth: number, season: number): void {\n if (forest.growth !== clampGrowth(growth)) forest.growth = growth;\n if (forest.season !== wrapSeason(season)) forest.season = season;\n\n const wanted = new Map<string, ForestTreePlacement>();\n for (const p of placements) {\n const key = forestTreeKey(p);\n if (wanted.has(key)) throw new Error(`<Forest> placements have two trees with key \"${key}\"`);\n wanted.set(key, p);\n }\n for (const tree of forest.trees) {\n const p = wanted.get(tree.key);\n if (!p || pose(p) !== pose(tree.placement)) forest.removeTree(tree);\n }\n for (const [key, p] of wanted) {\n const tree = forest.get(key) ?? forest.addTree(placementOf(p));\n const g = p.growth ?? growth;\n const s = p.season ?? season;\n if (tree.growth !== clampGrowth(g)) tree.growth = g;\n if (tree.season !== wrapSeason(s)) tree.season = s;\n }\n}\n\n/**\n * Many trees of one Definition, drawn instanced (a `Forest`). Changing `placements` plants or cuts\n * only the affected trees; Growth, Season, Wind and shadow props only update instance data, uniforms\n * and meshes. A new `definition` (by value), `style`/`form`, `variants` or `seed` rebuilds the forest.\n * The forest is disposed of on unmount.\n */\nexport function Forest({\n definition,\n style,\n form = 'broadleaf',\n variants = 4,\n seed = 0,\n placements,\n growth = 1,\n season = 0,\n wind,\n castShadow = true,\n receiveShadow = true,\n ref,\n ...groupProps\n}: ForestProps) {\n const styleObject = definition === undefined && typeof style === 'string' ? useTreeStyle(style) : style;\n const source = definition ?? (typeof styleObject === 'object' ? styleObject[form] : undefined);\n if (source === undefined) throw new Error('<Forest> needs a `definition` or a `style`.');\n const key = JSON.stringify(source);\n\n const [generation, setGeneration] = useState(0);\n const forest = useMemo(\n () => createForest(JSON.parse(key) as TreeDefinitionInput, [], { variants, seed, wind, growth, season }),\n // placements/growth/season/wind are synced by the layout effects below.\n [key, variants, seed, generation],\n );\n\n useEffect(() => {\n if (disposed.has(forest)) setGeneration((g) => g + 1);\n return () => {\n disposed.add(forest);\n forest.dispose();\n };\n }, [forest]);\n\n useLayoutEffect(() => {\n forest.wind = wind ?? sceneWind;\n }, [forest, wind]);\n\n useLayoutEffect(() => {\n syncForest(forest, placements, growth, season);\n }, [forest, placements, growth, season]);\n\n useLayoutEffect(() => {\n for (const variant of forest.variants) {\n for (const mesh of [variant.wood, variant.leaves]) {\n mesh.castShadow = castShadow;\n mesh.receiveShadow = receiveShadow;\n }\n }\n }, [forest, castShadow, receiveShadow, placements]);\n\n return <primitive object={forest} ref={ref} {...groupProps} />;\n}\n"],"mappings":";;;;AAKA,IAAM,wBAAQ,IAAI,IAAgC;AAElD,SAAS,cAAc,MAAqC;CAC1D,IAAI,UAAU,MAAM,IAAI,IAAI;CAC5B,IAAI,CAAC,SAAS;EACZ,UAAU,UAAU,IAAI;EACxB,MAAM,IAAI,MAAM,OAAO;EAEvB,QAAQ,YAAY,MAAM,OAAO,IAAI,CAAC;CACxC;CACA,OAAO;AACT;;;;;;;;;;AAWA,SAAgB,aAAa,MAA4B;CACvD,OAAO,IAAI,cAAc,IAAI,CAAC;AAChC;;AAGA,SAAgB,iBAAiB,MAAuB;CACtD,cAAmB,IAAI,CAAC,CAAC,YAAY,CAAC,CAAC;AACzC;;;ACIA,IAAMA,6BAAW,IAAI,QAAoB;;;;;;AAOzC,SAAgB,KAAK,EACnB,YACA,OACA,OAAO,aACP,OAAO,GACP,SAAS,GACT,SAAS,GACT,MACA,aAAa,MACb,gBAAgB,MAChB,KACA,GAAG,cACS;CAEZ,MAAM,cAAc,eAAe,KAAA,KAAa,OAAO,UAAU,WAAW,aAAa,KAAK,IAAI;CAClG,MAAM,SAAS,eAAe,OAA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B,WAAW,QAAQ,YAAY,QAAQ,MAAM;CAC/C,GAAG;EAAC;EAAQ;EAAY;EAAQ;CAAM,CAAC;CAEvC,sBAAsB;EACpB,KAAK,MAAM,WAAW,OAAO,UAC3B,KAAK,MAAM,QAAQ,CAAC,QAAQ,MAAM,QAAQ,MAAM,GAAG;GACjD,KAAK,aAAa;GAClB,KAAK,gBAAgB;EACvB;CAEJ,GAAG;EAAC;EAAQ;EAAY;EAAe;CAAU,CAAC;CAElD,OAAO,oBAAC,aAAD;EAAW,QAAQ;EAAa;EAAK,GAAI;CAAa,CAAA;AAC/D"}
1
+ {"version":3,"file":"react.js","names":["disposed"],"sources":["../src/react/useTreeStyle.ts","../src/react/Tree.tsx","../src/react/Wind.tsx","../src/react/Forest.tsx"],"sourcesContent":["import { use } from 'react';\nimport { loadStyle, type StyleName } from '../styles/registry';\nimport type { TreeStyle } from '../styles/types';\n\n// One promise per Style name, so every render (and every component) suspends on the same load.\nconst cache = new Map<string, Promise<TreeStyle>>();\n\nfunction styleResource(name: StyleName): Promise<TreeStyle> {\n let promise = cache.get(name);\n if (!promise) {\n promise = loadStyle(name);\n cache.set(name, promise);\n // A failed load is not cached, so a later render can retry (the error still reaches the error boundary).\n promise.catch(() => cache.delete(name));\n }\n return promise;\n}\n\n/**\n * Loads a built-in Style with a dynamic import and returns it. Suspends (React Suspense) while\n * it downloads, so wrap the component in `<Suspense>`. Unknown names throw to the nearest error boundary.\n *\n * ```tsx\n * const lowPoly = useTreeStyle('low-poly');\n * return <Tree style={lowPoly} form=\"conifer\" seed={7} />;\n * ```\n */\nexport function useTreeStyle(name: StyleName): TreeStyle {\n return use(styleResource(name));\n}\n\n/** Starts loading a Style ahead of time (e.g. on hover), without suspending. */\nexport function preloadTreeStyle(name: StyleName): void {\n void styleResource(name).catch(() => {});\n}\n","import { useEffect, useLayoutEffect, useMemo, useState, type Ref } from 'react';\nimport type { ThreeElements } from '@react-three/fiber';\nimport type { TreeDefinition, TreeDefinitionInput, TreeForm } from '../definition';\nimport type { SpeciesDefinition } from '../species/types';\nimport type { TreeStyle } from '../styles/types';\nimport type { StyleName } from '../styles/registry';\nimport { createTree, type Tree as TreeObject } from '../tree';\nimport { sceneWind, type Wind as WindObject } from '../wind';\nimport { useTreeStyle } from './useTreeStyle';\n\ntype GroupProps = Omit<ThreeElements['group'], 'args' | 'object' | 'children' | 'ref' | 'castShadow' | 'receiveShadow' | 'dispose'>;\n\nexport interface TreeProps extends GroupProps {\n /** The Tree Definition to grow (plain object or parsed JSON). Takes precedence over `style`. */\n definition?: TreeDefinitionInput | TreeDefinition;\n /**\n * A Style: its Definition for `form` is grown. Pass the object from {@link useTreeStyle}, or a\n * built-in Style name, which is loaded on demand (the component suspends until it is there).\n */\n style?: TreeStyle | StyleName;\n /** Which of the Style's Forms to grow. Default 'broadleaf'. */\n form?: TreeForm;\n /** A Species (e.g. `oak` from `@casmo/tree.js/species`) to grow in `style`: `style.apply(species)` instead of a Form. */\n species?: SpeciesDefinition;\n /** Picks one individual tree within the Definition's ranges. Default 0. Changing it regenerates the tree. */\n seed?: number;\n /** Growth 0 (sapling) .. 1 (default). Only updates a uniform. */\n growth?: number;\n /** Season 0 .. 1 (wraps). Only updates a uniform. */\n season?: number;\n /** The Wind this tree sways with. Default: the scene-wide `sceneWind` (what `<Wind>` sets). */\n wind?: WindObject;\n /** Whether the tree casts shadows. Default true. */\n castShadow?: boolean;\n /** Whether the tree receives shadows. Default true. */\n receiveShadow?: boolean;\n /** Receives the tree.js `Tree` object (a three.js Group). */\n ref?: Ref<TreeObject>;\n}\n\n/** Trees this module has disposed of (React StrictMode re-runs effects on the same memoised tree). */\nconst disposed = new WeakSet<TreeObject>();\n\n/**\n * A procedural tree. Growth, Season, Wind and shadow props only update the existing tree; a new\n * `seed`, `definition` (by value) or `style`/`form`/`species` regenerates it. The tree is disposed\n * of on unmount.\n */\nexport function Tree({\n definition,\n style,\n form = 'broadleaf',\n species,\n seed = 0,\n growth = 1,\n season = 0,\n wind,\n castShadow = true,\n receiveShadow = true,\n ref,\n ...groupProps\n}: TreeProps) {\n // `use()` (behind useTreeStyle) may be called conditionally, so a style name suspends right here.\n const styleObject = definition === undefined && typeof style === 'string' ? useTreeStyle(style) : style;\n const source = definition ?? (typeof styleObject === 'object' ? (species ? styleObject.apply(species) : styleObject[form]) : undefined);\n if (source === undefined) throw new Error('<Tree> needs a `definition` or a `style`.');\n // Compare Definitions by value, so an inline object literal does not regenerate on every render.\n const key = JSON.stringify(source);\n\n // Bumped when StrictMode disposed the memoised tree, to grow a fresh one.\n const [generation, setGeneration] = useState(0);\n const tree = useMemo(\n () => createTree(JSON.parse(key) as TreeDefinitionInput, { seed, wind, growth, season }),\n // growth/season/wind are only the starting values; the effects below keep them in sync.\n [key, seed, generation],\n );\n\n useEffect(() => {\n if (disposed.has(tree)) setGeneration((g) => g + 1);\n return () => {\n disposed.add(tree);\n tree.dispose();\n };\n }, [tree]);\n\n useLayoutEffect(() => {\n tree.wind = wind ?? sceneWind;\n }, [tree, wind]);\n\n useLayoutEffect(() => {\n tree.growth = growth;\n }, [tree, growth]);\n\n useLayoutEffect(() => {\n tree.season = season;\n }, [tree, season]);\n\n useLayoutEffect(() => {\n for (const mesh of [tree.wood, tree.leaves, tree.fruit]) {\n mesh.castShadow = castShadow;\n mesh.receiveShadow = receiveShadow;\n }\n }, [tree, castShadow, receiveShadow]);\n\n return <primitive object={tree} ref={ref} {...groupProps} />;\n}\n","import { useLayoutEffect } from 'react';\nimport { sceneWind, type Wind as WindObject, type WindDirection } from '../wind';\n\nexport interface WindProps {\n /** World-space direction the wind blows towards (any non-zero length). Unset: leave as is (default +X). */\n direction?: WindDirection;\n /** 0 = calm, 1 = strong wind, more for storms. Unset: leave as is (default 0). */\n strength?: number;\n /** Pins the Wind clock to this many seconds (pause, screenshots). Unset: the renderer clock. */\n time?: number | null;\n /** The Wind to drive. Default: the scene-wide `sceneWind` every `<Tree>` sways with. */\n wind?: WindObject;\n}\n\n/**\n * Declares the Wind. Renders nothing; it writes the Wind's uniforms (no recompile), and puts back the\n * direction, strength and clock it found when it unmounts.\n */\nexport function Wind({ direction, strength, time = null, wind = sceneWind }: WindProps): null {\n // Depend on the components, so a new array literal with the same values does nothing.\n const [x, y, z] = direction === undefined ? [] : Array.isArray(direction) ? direction : (direction as { toArray(): number[] }).toArray();\n\n useLayoutEffect(() => {\n const previous = { direction: wind.direction, strength: wind.strength, time: wind.time };\n return () => {\n wind.set(previous);\n wind.time = previous.time;\n };\n }, [wind]);\n\n useLayoutEffect(() => {\n if (x !== undefined) wind.direction = [x, y!, z!];\n }, [wind, x, y, z]);\n\n useLayoutEffect(() => {\n if (strength !== undefined) wind.strength = strength;\n }, [wind, strength]);\n\n useLayoutEffect(() => {\n wind.time = time;\n }, [wind, time]);\n\n return null;\n}\n","import { useEffect, useLayoutEffect, useMemo, useState, type Ref } from 'react';\nimport type { ThreeElements } from '@react-three/fiber';\nimport type { TreeDefinition, TreeDefinitionInput, TreeForm } from '../definition';\nimport type { TreeStyle } from '../styles/types';\nimport type { StyleName } from '../styles/registry';\nimport { createForest, type Forest as ForestObject } from '../forest';\nimport { forestTreeKey, type ForestPlacement } from '../forest/placement';\nimport { clampGrowth } from '../growth/evaluate';\nimport { wrapSeason } from '../season/profile';\nimport { sceneWind, type Wind as WindObject } from '../wind';\nimport { useTreeStyle } from './useTreeStyle';\n\ntype GroupProps = Omit<ThreeElements['group'], 'args' | 'object' | 'children' | 'ref' | 'castShadow' | 'receiveShadow' | 'dispose'>;\n\n/** Where one tree of a `<Forest>` stands, optionally with its own Growth and Season. */\nexport interface ForestTreePlacement extends ForestPlacement {\n /** This tree's Growth, 0..1. Default: the forest's `growth`. */\n growth?: number;\n /** This tree's Season, 0..1 (wraps). Default: the forest's `season`. */\n season?: number;\n}\n\nexport interface ForestProps extends GroupProps {\n /** The Tree Definition every tree is grown from (plain object or parsed JSON). Takes precedence over `style`. */\n definition?: TreeDefinitionInput | TreeDefinition;\n /** A Style (object from {@link useTreeStyle}, or a built-in Style name, loaded on demand: suspends). */\n style?: TreeStyle | StyleName;\n /** Which of the Style's Forms to grow. Default 'broadleaf'. */\n form?: TreeForm;\n /** How many Variants (distinct trees, each drawn instanced). Default 4. Changing it rebuilds the forest. */\n variants?: number;\n /** The forest seed. Default 0. Changing it rebuilds the forest. */\n seed?: number;\n /**\n * The trees. Trees are matched by key (their `id`, or their position without one), so adding or\n * removing placements only plants or cuts those trees; the others keep their look and instance data.\n */\n placements: readonly ForestTreePlacement[];\n /** Growth of every tree without its own `growth`, 0..1. Default 1. Only rewrites instance data. */\n growth?: number;\n /** Season of every tree without its own `season`, 0..1 (wraps). Default 0. Only rewrites instance data. */\n season?: number;\n /** The Wind the forest sways with. Default: the scene-wide `sceneWind` (what `<Wind>` sets). */\n wind?: WindObject;\n /** Whether the trees cast shadows. Default true. */\n castShadow?: boolean;\n /** Whether the trees receive shadows. Default true. */\n receiveShadow?: boolean;\n /** Receives the tree.js `Forest` object (a three.js Group). */\n ref?: Ref<ForestObject>;\n}\n\n/** Forests this module has disposed of (React StrictMode re-runs effects on the same memoised forest). */\nconst disposed = new WeakSet<ForestObject>();\n\n/** The placement without the React-only per-tree state. */\nfunction placementOf(p: ForestTreePlacement): ForestPlacement {\n const placement = { ...p };\n delete placement.growth;\n delete placement.season;\n return placement;\n}\n\n/** What makes a tree stand where it does; a change re-plants the tree. */\nfunction pose(p: ForestPlacement): string {\n const v = p.position;\n const position = Array.isArray(v) ? [v[0], v[1], v[2]] : [(v as { x: number }).x, (v as { y: number }).y, (v as { z: number }).z];\n return JSON.stringify([position, p.rotation ?? 0, p.scale ?? 1]);\n}\n\n/**\n * Brings `forest` in line with `placements`: cuts trees that are no longer placed, plants new ones,\n * re-plants moved ones, and writes Growth/Season only where they differ. Untouched trees are not rewritten.\n */\nfunction syncForest(forest: ForestObject, placements: readonly ForestTreePlacement[], growth: number, season: number): void {\n if (forest.growth !== clampGrowth(growth)) forest.growth = growth;\n if (forest.season !== wrapSeason(season)) forest.season = season;\n\n const wanted = new Map<string, ForestTreePlacement>();\n for (const p of placements) {\n const key = forestTreeKey(p);\n if (wanted.has(key)) throw new Error(`<Forest> placements have two trees with key \"${key}\"`);\n wanted.set(key, p);\n }\n for (const tree of forest.trees) {\n const p = wanted.get(tree.key);\n if (!p || pose(p) !== pose(tree.placement)) forest.removeTree(tree);\n }\n for (const [key, p] of wanted) {\n const tree = forest.get(key) ?? forest.addTree(placementOf(p));\n const g = p.growth ?? growth;\n const s = p.season ?? season;\n if (tree.growth !== clampGrowth(g)) tree.growth = g;\n if (tree.season !== wrapSeason(s)) tree.season = s;\n }\n}\n\n/**\n * Many trees of one Definition, drawn instanced (a `Forest`). Changing `placements` plants or cuts\n * only the affected trees; Growth, Season, Wind and shadow props only update instance data, uniforms\n * and meshes. A new `definition` (by value), `style`/`form`, `variants` or `seed` rebuilds the forest.\n * The forest is disposed of on unmount.\n */\nexport function Forest({\n definition,\n style,\n form = 'broadleaf',\n variants = 4,\n seed = 0,\n placements,\n growth = 1,\n season = 0,\n wind,\n castShadow = true,\n receiveShadow = true,\n ref,\n ...groupProps\n}: ForestProps) {\n const styleObject = definition === undefined && typeof style === 'string' ? useTreeStyle(style) : style;\n const source = definition ?? (typeof styleObject === 'object' ? styleObject[form] : undefined);\n if (source === undefined) throw new Error('<Forest> needs a `definition` or a `style`.');\n const key = JSON.stringify(source);\n\n const [generation, setGeneration] = useState(0);\n const forest = useMemo(\n () => createForest(JSON.parse(key) as TreeDefinitionInput, [], { variants, seed, wind, growth, season }),\n // placements/growth/season/wind are synced by the layout effects below.\n [key, variants, seed, generation],\n );\n\n useEffect(() => {\n if (disposed.has(forest)) setGeneration((g) => g + 1);\n return () => {\n disposed.add(forest);\n forest.dispose();\n };\n }, [forest]);\n\n useLayoutEffect(() => {\n forest.wind = wind ?? sceneWind;\n }, [forest, wind]);\n\n useLayoutEffect(() => {\n syncForest(forest, placements, growth, season);\n }, [forest, placements, growth, season]);\n\n useLayoutEffect(() => {\n for (const variant of forest.variants) {\n for (const mesh of variant.meshes) {\n mesh.castShadow = castShadow;\n mesh.receiveShadow = receiveShadow;\n }\n }\n }, [forest, castShadow, receiveShadow, placements]);\n\n return <primitive object={forest} ref={ref} {...groupProps} />;\n}\n"],"mappings":";;;;AAKA,IAAM,wBAAQ,IAAI,IAAgC;AAElD,SAAS,cAAc,MAAqC;CAC1D,IAAI,UAAU,MAAM,IAAI,IAAI;CAC5B,IAAI,CAAC,SAAS;EACZ,UAAU,UAAU,IAAI;EACxB,MAAM,IAAI,MAAM,OAAO;EAEvB,QAAQ,YAAY,MAAM,OAAO,IAAI,CAAC;CACxC;CACA,OAAO;AACT;;;;;;;;;;AAWA,SAAgB,aAAa,MAA4B;CACvD,OAAO,IAAI,cAAc,IAAI,CAAC;AAChC;;AAGA,SAAgB,iBAAiB,MAAuB;CACtD,cAAmB,IAAI,CAAC,CAAC,YAAY,CAAC,CAAC;AACzC;;;ACOA,IAAMA,6BAAW,IAAI,QAAoB;;;;;;AAOzC,SAAgB,KAAK,EACnB,YACA,OACA,OAAO,aACP,SACA,OAAO,GACP,SAAS,GACT,SAAS,GACT,MACA,aAAa,MACb,gBAAgB,MAChB,KACA,GAAG,cACS;CAEZ,MAAM,cAAc,eAAe,KAAA,KAAa,OAAO,UAAU,WAAW,aAAa,KAAK,IAAI;CAClG,MAAM,SAAS,eAAe,OAAO,gBAAgB,WAAY,UAAU,YAAY,MAAM,OAAO,IAAI,YAAY,QAAS,KAAA;CAC7H,IAAI,WAAW,KAAA,GAAW,MAAM,IAAI,MAAM,2CAA2C;CAErF,MAAM,MAAM,KAAK,UAAU,MAAM;CAGjC,MAAM,CAAC,YAAY,iBAAiB,SAAS,CAAC;CAC9C,MAAM,OAAO,cACL,WAAW,KAAK,MAAM,GAAG,GAA0B;EAAE;EAAM;EAAM;EAAQ;CAAO,CAAC,GAEvF;EAAC;EAAK;EAAM;CAAU,CACxB;CAEA,gBAAgB;EACd,IAAIA,WAAS,IAAI,IAAI,GAAG,eAAe,MAAM,IA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22,22 @@ export interface SeasonNodes<S extends FloatNode<'float'> = SeasonUniform> {
22
22
  */
23
23
  export declare function createSeasonNodes(profile: SeasonProfileDefinition): SeasonNodes;
24
24
  export declare function createSeasonNodes<S extends FloatNode<'float'>>(profile: SeasonProfileDefinition, season: S): SeasonNodes<S>;
25
+ /** The Season nodes of one tree's Fruit. */
26
+ export interface FruitSeasonNodes {
27
+ /** Fruit colour (vec3, linear) at this Fruit's shifted Season. */
28
+ color: Node;
29
+ /** Size of the Fruit (0 = not set or dropped .. 1 = full size). */
30
+ scale: Node;
31
+ /** The vertex position (default `positionLocal`) scaled about the Fruit's attachment point (`aOrigin`) by `scale`. */
32
+ position: Node;
33
+ }
34
+ /**
35
+ * Builds the TSL nodes that evaluate the Season Profile's Fruit tracks per Fruit, from the fruit
36
+ * mesh's `aSeason` (timing shift, Fruit rank). The TSL twin of `fruitSeason`: a Fruit shows while
37
+ * the Fruit amount is above its rank and swells with the amount. `season` is the Season input
38
+ * (share the leaves' uniform so one write drives both).
39
+ */
40
+ export declare function createFruitSeasonNodes(profile: SeasonProfileDefinition, season: FloatNode<'float'>, position?: Node): FruitSeasonNodes;
25
41
  /**
26
42
  * Hooks Season into a leaf material: `colorNode` (times the vertex-colour tint, and times the
27
43
  * material's existing `colorNode`, such as a leaf card texture with alpha) and `maskNode`, which
@@ -1 +1 @@
1
- {"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../src/season/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,IAAI,IAAI,SAAS,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAElG,OAAO,KAAK,EAAY,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAGvE,gDAAgD;AAChD,MAAM,MAAM,aAAa,GAAG,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAIzD,KAAK,IAAI,GAAG,GAAG,CAAC;AAkBhB,kGAAkG;AAClG,MAAM,WAAW,WAAW,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AAuB,GAAG,WAAW,CAAC;AACjF,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,SAAS,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,uBAAuB,EAAE,MAAM,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;AAyB7H,4CAA4C;AAC5C,MAAM,WAAW,gBAAgB;IAC/B,kEAAkE;IAClE,KAAK,EAAE,IAAI,CAAC;IACZ,mEAAmE;IACnE,KAAK,EAAE,IAAI,CAAC;IACZ,sHAAsH;IACtH,QAAQ,EAAE,IAAI,CAAC;CAChB;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,uBAAuB,EAChC,MAAM,EAAE,SAAS,CAAC,OAAO,CAAC,EAC1B,QAAQ,GAAE,IAAoB,GAC7B,gBAAgB,CAYlB;AAED;;;;GAIG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,YAAY,EAAE,KAAK,EAAE,IAAI,CAAC,WAAW,EAAE,OAAO,GAAG,SAAS,CAAC,GAAG,IAAI,CAGrH"}
@@ -32,7 +32,16 @@ export interface SeasonState {
32
32
  /** 0 = none .. 1 = full bloom. */
33
33
  blossom: number;
34
34
  blossomColor: RGB;
35
+ /** Fruit amount: 0 = none .. 1 = all Fruit at full size (1 without a `fruit` track). */
36
+ fruit: number;
37
+ /** Fruit colour (the default red without a `fruitColor` track). */
38
+ fruitColor: RGB;
35
39
  }
40
+ /** A Season Profile's Fruit tracks, with the defaults for absent ones. */
41
+ export declare function fruitTracks(profile: SeasonProfileDefinition): {
42
+ fruit: Keyframe<number>[];
43
+ fruitColor: Keyframe<HexColor>[];
44
+ };
36
45
  /**
37
46
  * Evaluates the Season Profile at `season`, shifted by `shift` (a Seed's timing offset,
38
47
  * see {@link seasonShift}) and wrapped around the year.
@@ -59,6 +68,8 @@ export declare function partSeasonAt(aSeason: ArrayLike<number>, vertex: number)
59
68
  export declare function seasonShift(seed: number, variation: Pick<VariationDefinition, 'season'>): number;
60
69
  /** The Season timing (`aSeason` attribute) of one leaf; see {@link PartSeason}. */
61
70
  export declare function leafSeasonAttribute(seed: number, variation: Pick<VariationDefinition, 'season'>, leafId: string): PartSeason;
71
+ /** The Season timing (`aSeason` attribute) of one Fruit: like a leaf's, with the Fruit's rank as `coverageRank`. */
72
+ export declare function fruitSeasonAttribute(seed: number, variation: Pick<VariationDefinition, 'season'>, fruitId: string): PartSeason;
62
73
  /** `aSeason` for wood vertices: the tree's timing shift, no ranks. */
63
74
  export declare function woodSeasonAttribute(seed: number, variation: Pick<VariationDefinition, 'season'>): PartSeason;
64
75
  /** One leaf at one Season. */
@@ -75,4 +86,19 @@ export interface LeafSeasonState {
75
86
  * exact CPU twin of the leaf shader (see `createSeasonNodes`). Use it to bake a tree at a Season.
76
87
  */
77
88
  export declare function leafSeason(profile: SeasonProfileDefinition, season: number, part: PartSeason): LeafSeasonState;
89
+ /** One Fruit at one Season. */
90
+ export interface FruitSeasonState {
91
+ /** False when the Fruit has not set yet or has dropped (the Fruit amount is not above its rank). */
92
+ visible: boolean;
93
+ /** Size of the Fruit relative to full size (0 when not visible): it swells with the Fruit amount. */
94
+ scale: number;
95
+ /** Linear RGB before the Seed's per-Fruit tint (vertex colour) is multiplied in. */
96
+ color: RGB;
97
+ }
98
+ /**
99
+ * Evaluates one Fruit from its Season timing (`aSeason` of the fruit mesh: shift, the Fruit's
100
+ * rank as `coverageRank`): the exact CPU twin of the Fruit shader (see `createFruitSeasonNodes`).
101
+ * A Fruit shows while the Fruit amount is above its rank, scaled about its attachment point by the amount.
102
+ */
103
+ export declare function fruitSeason(profile: SeasonProfileDefinition, season: number, part: PartSeason): FruitSeasonState;
78
104
  //# sourceMappingURL=profile.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"profile.d.ts","sourceRoot":"","sources":["../../src/season/profile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,uBAAuB,EAAE,mBAAmB,EAAE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KAAK,EAAE,MAAM,CAAC;IACd,oFAAoF;IACpF,KAAK,EAAE,GAAG,CAAC;CACZ;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,uBAAuB,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,gBAAgB,CAIhH"}
@@ -0,0 +1,223 @@
1
+ // src/species/data/almond.json
2
+ var id = "almond";
3
+ var name = "Almond";
4
+ var form = "broadleaf";
5
+ var trunk = {
6
+ "length": 2.6,
7
+ "radius": .2,
8
+ "taper": .4,
9
+ "lengthVariation": .12,
10
+ "bend": .22,
11
+ "flare": .4
12
+ };
13
+ var branches = [
14
+ {
15
+ "angleVariation": .15,
16
+ "spiral": 137.5,
17
+ "lengthVariation": .15,
18
+ "taper": .45,
19
+ "bend": .2,
20
+ "gravity": .05,
21
+ "angleProfile": [{
22
+ "t": .45,
23
+ "value": 1.1
24
+ }, {
25
+ "t": 1,
26
+ "value": .85
27
+ }],
28
+ "count": 5,
29
+ "start": .45,
30
+ "end": .95,
31
+ "angle": 32,
32
+ "length": 1.1,
33
+ "radius": .6
34
+ },
35
+ {
36
+ "angleVariation": .15,
37
+ "spiral": 137.5,
38
+ "lengthVariation": .15,
39
+ "taper": .45,
40
+ "bend": .2,
41
+ "gravity": .2,
42
+ "count": 3,
43
+ "start": .3,
44
+ "end": 1,
45
+ "angle": 38,
46
+ "length": .5,
47
+ "radius": .6
48
+ },
49
+ {
50
+ "angleVariation": .15,
51
+ "spiral": 137.5,
52
+ "lengthVariation": .15,
53
+ "taper": .45,
54
+ "bend": .15,
55
+ "gravity": .25,
56
+ "count": 3,
57
+ "start": .3,
58
+ "end": 1,
59
+ "angle": 35,
60
+ "length": .45,
61
+ "radius": .6
62
+ }
63
+ ];
64
+ var foliage = {
65
+ "type": "broad",
66
+ "density": .45,
67
+ "size": .4,
68
+ "sizeVariation": .25,
69
+ "start": .1,
70
+ "angle": 50
71
+ };
72
+ var bark = {
73
+ "type": "furrowed",
74
+ "color": "#7a6e64"
75
+ };
76
+ var fruit = {
77
+ "type": "nut",
78
+ "count": .4,
79
+ "size": .3,
80
+ "sizeVariation": .15,
81
+ "hang": .5
82
+ };
83
+ var roots = {
84
+ "count": 5,
85
+ "length": .2,
86
+ "lengthVariation": .3,
87
+ "radius": .3,
88
+ "angle": 14,
89
+ "bend": .3
90
+ };
91
+ var season = {
92
+ "leafColor": [
93
+ {
94
+ "t": 0,
95
+ "value": "#a9c95e"
96
+ },
97
+ {
98
+ "t": .2,
99
+ "value": "#62844a"
100
+ },
101
+ {
102
+ "t": .56,
103
+ "value": "#62844a"
104
+ },
105
+ {
106
+ "t": .62,
107
+ "value": "#b8a03a"
108
+ },
109
+ {
110
+ "t": .72,
111
+ "value": "#9a7030"
112
+ },
113
+ {
114
+ "t": 1,
115
+ "value": "#9a7030"
116
+ }
117
+ ],
118
+ "leafCoverage": [
119
+ {
120
+ "t": 0,
121
+ "value": 0
122
+ },
123
+ {
124
+ "t": .06,
125
+ "value": 0
126
+ },
127
+ {
128
+ "t": .17,
129
+ "value": 1
130
+ },
131
+ {
132
+ "t": .62,
133
+ "value": 1
134
+ },
135
+ {
136
+ "t": .74,
137
+ "value": 0
138
+ }
139
+ ],
140
+ "blossom": [
141
+ {
142
+ "t": 0,
143
+ "value": 0
144
+ },
145
+ {
146
+ "t": .005,
147
+ "value": 0
148
+ },
149
+ {
150
+ "t": .05,
151
+ "value": 1
152
+ },
153
+ {
154
+ "t": .082,
155
+ "value": .9
156
+ },
157
+ {
158
+ "t": .13,
159
+ "value": 0
160
+ }
161
+ ],
162
+ "blossomColor": "#f8dbe4",
163
+ "fruit": [
164
+ {
165
+ "t": .14,
166
+ "value": 0
167
+ },
168
+ {
169
+ "t": .3,
170
+ "value": 1
171
+ },
172
+ {
173
+ "t": .56,
174
+ "value": 1
175
+ },
176
+ {
177
+ "t": .64,
178
+ "value": 0
179
+ }
180
+ ],
181
+ "fruitColor": [
182
+ {
183
+ "t": .24,
184
+ "value": "#8aa64a"
185
+ },
186
+ {
187
+ "t": .4,
188
+ "value": "#9a9a52"
189
+ },
190
+ {
191
+ "t": .5,
192
+ "value": "#a07850"
193
+ }
194
+ ]
195
+ };
196
+ var wind = {
197
+ "trunk": .06,
198
+ "branches": .32,
199
+ "leaves": .65,
200
+ "frequency": 1
201
+ };
202
+ var variation = {
203
+ "color": .1,
204
+ "growth": .1,
205
+ "season": .05
206
+ };
207
+ var almond_default = {
208
+ id,
209
+ name,
210
+ form,
211
+ trunk,
212
+ branches,
213
+ foliage,
214
+ bark,
215
+ fruit,
216
+ roots,
217
+ season,
218
+ wind,
219
+ variation
220
+ };
221
+ export { bark, branches, almond_default as default, foliage, form, fruit, id, name, roots, season, trunk, variation, wind };
222
+
223
+ //# sourceMappingURL=almond.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"almond.js","names":[],"sources":[],"mappings":""}