@casmo/tree.js 0.2.0 → 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 (136) hide show
  1. package/README.md +206 -0
  2. package/dist/{apply-CcodnAbs.js → apply-Cio2t7CZ.js} +51 -16
  3. package/dist/apply-Cio2t7CZ.js.map +1 -0
  4. package/dist/bake/index.d.ts +43 -4
  5. package/dist/bake/index.d.ts.map +1 -1
  6. package/dist/definition/defaults.d.ts +9 -1
  7. package/dist/definition/defaults.d.ts.map +1 -1
  8. package/dist/definition/index.d.ts +2 -2
  9. package/dist/definition/index.d.ts.map +1 -1
  10. package/dist/definition/schema.d.ts.map +1 -1
  11. package/dist/definition/types.d.ts +86 -0
  12. package/dist/definition/types.d.ts.map +1 -1
  13. package/dist/forest/Forest.d.ts +27 -1
  14. package/dist/forest/Forest.d.ts.map +1 -1
  15. package/dist/forest/nodes.d.ts +2 -0
  16. package/dist/forest/nodes.d.ts.map +1 -1
  17. package/dist/{forest-DTrD8puH.js → forest-ChEaWJrf.js} +1121 -191
  18. package/dist/forest-ChEaWJrf.js.map +1 -0
  19. package/dist/generator/crown.d.ts +28 -0
  20. package/dist/generator/crown.d.ts.map +1 -0
  21. package/dist/generator/growth.d.ts +1 -1
  22. package/dist/generator/growth.d.ts.map +1 -1
  23. package/dist/generator/index.d.ts +2 -1
  24. package/dist/generator/index.d.ts.map +1 -1
  25. package/dist/generator/mesh.d.ts +10 -2
  26. package/dist/generator/mesh.d.ts.map +1 -1
  27. package/dist/generator/occlusion.d.ts +8 -0
  28. package/dist/generator/occlusion.d.ts.map +1 -0
  29. package/dist/generator/roots.d.ts +16 -0
  30. package/dist/generator/roots.d.ts.map +1 -0
  31. package/dist/generator/trunk.d.ts +8 -0
  32. package/dist/generator/trunk.d.ts.map +1 -1
  33. package/dist/generator/types.d.ts +27 -1
  34. package/dist/generator/types.d.ts.map +1 -1
  35. package/dist/growth/index.d.ts +1 -1
  36. package/dist/growth/index.d.ts.map +1 -1
  37. package/dist/growth/tsl.d.ts +2 -0
  38. package/dist/growth/tsl.d.ts.map +1 -1
  39. package/dist/index.d.ts +4 -3
  40. package/dist/index.d.ts.map +1 -1
  41. package/dist/index.js +234 -28
  42. package/dist/index.js.map +1 -1
  43. package/dist/materials/crown-nodes.d.ts +20 -0
  44. package/dist/materials/crown-nodes.d.ts.map +1 -0
  45. package/dist/materials/crown-normals.d.ts +17 -0
  46. package/dist/materials/crown-normals.d.ts.map +1 -0
  47. package/dist/materials/ground-tint.d.ts +13 -0
  48. package/dist/materials/ground-tint.d.ts.map +1 -0
  49. package/dist/materials/index.d.ts +7 -1
  50. package/dist/materials/index.d.ts.map +1 -1
  51. package/dist/materials/leaf-translucency-model.d.ts +14 -0
  52. package/dist/materials/leaf-translucency-model.d.ts.map +1 -0
  53. package/dist/materials/leaf-translucency.d.ts +73 -0
  54. package/dist/materials/leaf-translucency.d.ts.map +1 -0
  55. package/dist/materials/material-features.d.ts +43 -0
  56. package/dist/materials/material-features.d.ts.map +1 -0
  57. package/dist/materials/occlusion.d.ts +10 -0
  58. package/dist/materials/occlusion.d.ts.map +1 -0
  59. package/dist/materials/toon.d.ts +18 -1
  60. package/dist/materials/toon.d.ts.map +1 -1
  61. package/dist/{names-C6-wuJ29.js → names-BE9he6CS.js} +133 -9
  62. package/dist/names-BE9he6CS.js.map +1 -0
  63. package/dist/react.js +1 -1
  64. package/dist/species/almond.js +12 -2
  65. package/dist/species/almond.json +10 -1
  66. package/dist/species/apple.js +12 -2
  67. package/dist/species/apple.json +10 -1
  68. package/dist/species/ash.js +12 -2
  69. package/dist/species/ash.json +10 -1
  70. package/dist/species/beech.js +12 -2
  71. package/dist/species/beech.json +10 -1
  72. package/dist/species/birch.js +12 -2
  73. package/dist/species/birch.json +10 -1
  74. package/dist/species/cedar.js +12 -2
  75. package/dist/species/cedar.json +10 -1
  76. package/dist/species/cherry.js +12 -2
  77. package/dist/species/cherry.json +10 -1
  78. package/dist/species/chestnut.js +12 -2
  79. package/dist/species/chestnut.json +10 -1
  80. package/dist/species/douglas-fir.js +12 -2
  81. package/dist/species/douglas-fir.json +10 -1
  82. package/dist/species/elm.js +12 -2
  83. package/dist/species/elm.json +10 -1
  84. package/dist/species/hemlock.js +12 -2
  85. package/dist/species/hemlock.json +10 -1
  86. package/dist/species/hickory.js +12 -2
  87. package/dist/species/hickory.json +10 -1
  88. package/dist/species/juniper.js +12 -2
  89. package/dist/species/juniper.json +10 -1
  90. package/dist/species/mahogany.js +12 -2
  91. package/dist/species/mahogany.json +10 -1
  92. package/dist/species/maple.js +12 -2
  93. package/dist/species/maple.json +10 -1
  94. package/dist/species/oak.js +12 -2
  95. package/dist/species/oak.json +10 -1
  96. package/dist/species/olive.js +12 -2
  97. package/dist/species/olive.json +10 -1
  98. package/dist/species/peach.js +12 -2
  99. package/dist/species/peach.json +10 -1
  100. package/dist/species/pear.js +12 -2
  101. package/dist/species/pear.json +10 -1
  102. package/dist/species/pine.js +12 -2
  103. package/dist/species/pine.json +10 -1
  104. package/dist/species/plum.js +12 -2
  105. package/dist/species/plum.json +10 -1
  106. package/dist/species/red-oak.js +12 -2
  107. package/dist/species/red-oak.json +10 -1
  108. package/dist/species/redwood.js +12 -2
  109. package/dist/species/redwood.json +10 -1
  110. package/dist/species/sequoia.js +12 -2
  111. package/dist/species/sequoia.json +10 -1
  112. package/dist/species/spruce.js +12 -2
  113. package/dist/species/spruce.json +10 -1
  114. package/dist/species/teak.js +12 -2
  115. package/dist/species/teak.json +10 -1
  116. package/dist/species/types.d.ts +7 -3
  117. package/dist/species/types.d.ts.map +1 -1
  118. package/dist/species/walnut.js +12 -2
  119. package/dist/species/walnut.json +10 -1
  120. package/dist/species/white-oak.js +12 -2
  121. package/dist/species/white-oak.json +10 -1
  122. package/dist/styles/apply.d.ts.map +1 -1
  123. package/dist/styles/low-poly.js +6 -4
  124. package/dist/styles/low-poly.js.map +1 -1
  125. package/dist/styles/material-features.d.ts +27 -0
  126. package/dist/styles/material-features.d.ts.map +1 -0
  127. package/dist/styles/realistic.js +6 -4
  128. package/dist/styles/realistic.js.map +1 -1
  129. package/dist/styles/stylized.js +6 -4
  130. package/dist/styles/stylized.js.map +1 -1
  131. package/dist/tree/Tree.d.ts +28 -1
  132. package/dist/tree/Tree.d.ts.map +1 -1
  133. package/package.json +1 -1
  134. package/dist/apply-CcodnAbs.js.map +0 -1
  135. package/dist/forest-DTrD8puH.js.map +0 -1
  136. package/dist/names-C6-wuJ29.js.map +0 -1
@@ -7,7 +7,8 @@ var trunk = {
7
7
  "radius": .24,
8
8
  "taper": .1,
9
9
  "lengthVariation": .12,
10
- "bend": .02
10
+ "bend": .02,
11
+ "flare": .15
11
12
  };
12
13
  var branches = [{
13
14
  "angleVariation": .06,
@@ -83,6 +84,14 @@ var fruit = {
83
84
  "sizeVariation": .2,
84
85
  "hang": 1
85
86
  };
87
+ var roots = {
88
+ "count": 3,
89
+ "length": .1,
90
+ "lengthVariation": .3,
91
+ "radius": .22,
92
+ "angle": 20,
93
+ "bend": .25
94
+ };
86
95
  var season = {
87
96
  "leafColor": [
88
97
  {
@@ -151,10 +160,11 @@ var spruce_default = {
151
160
  foliage,
152
161
  bark,
153
162
  fruit,
163
+ roots,
154
164
  season,
155
165
  wind,
156
166
  variation
157
167
  };
158
- export { bark, branches, spruce_default as default, foliage, form, fruit, id, name, season, trunk, variation, wind };
168
+ export { bark, branches, spruce_default as default, foliage, form, fruit, id, name, roots, season, trunk, variation, wind };
159
169
 
160
170
  //# sourceMappingURL=spruce.js.map
@@ -7,7 +7,8 @@
7
7
  "radius": 0.24,
8
8
  "taper": 0.1,
9
9
  "lengthVariation": 0.12,
10
- "bend": 0.02
10
+ "bend": 0.02,
11
+ "flare": 0.15
11
12
  },
12
13
  "branches": [
13
14
  {
@@ -86,6 +87,14 @@
86
87
  "sizeVariation": 0.2,
87
88
  "hang": 1
88
89
  },
90
+ "roots": {
91
+ "count": 3,
92
+ "length": 0.1,
93
+ "lengthVariation": 0.3,
94
+ "radius": 0.22,
95
+ "angle": 20,
96
+ "bend": 0.25
97
+ },
89
98
  "season": {
90
99
  "leafColor": [
91
100
  {
@@ -7,7 +7,8 @@ var trunk = {
7
7
  "radius": .4,
8
8
  "taper": .36,
9
9
  "lengthVariation": .1,
10
- "bend": .08
10
+ "bend": .08,
11
+ "flare": .8
11
12
  };
12
13
  var branches = [{
13
14
  "angleVariation": .15,
@@ -55,6 +56,14 @@ var bark = {
55
56
  "type": "fibrous",
56
57
  "color": "#a39886"
57
58
  };
59
+ var roots = {
60
+ "count": 7,
61
+ "length": .3,
62
+ "lengthVariation": .3,
63
+ "radius": .4,
64
+ "angle": 10,
65
+ "bend": .35
66
+ };
58
67
  var season = {
59
68
  "leafColor": [
60
69
  {
@@ -147,10 +156,11 @@ var teak_default = {
147
156
  branches,
148
157
  foliage,
149
158
  bark,
159
+ roots,
150
160
  season,
151
161
  wind,
152
162
  variation
153
163
  };
154
- export { bark, branches, teak_default as default, foliage, form, id, name, season, trunk, variation, wind };
164
+ export { bark, branches, teak_default as default, foliage, form, id, name, roots, season, trunk, variation, wind };
155
165
 
156
166
  //# sourceMappingURL=teak.js.map
@@ -7,7 +7,8 @@
7
7
  "radius": 0.4,
8
8
  "taper": 0.36,
9
9
  "lengthVariation": 0.1,
10
- "bend": 0.08
10
+ "bend": 0.08,
11
+ "flare": 0.8
11
12
  },
12
13
  "branches": [
13
14
  {
@@ -61,6 +62,14 @@
61
62
  "type": "fibrous",
62
63
  "color": "#a39886"
63
64
  },
65
+ "roots": {
66
+ "count": 7,
67
+ "length": 0.3,
68
+ "lengthVariation": 0.3,
69
+ "radius": 0.4,
70
+ "angle": 10,
71
+ "bend": 0.35
72
+ },
64
73
  "season": {
65
74
  "leafColor": [
66
75
  {
@@ -1,10 +1,10 @@
1
- import type { BarkType, BranchLevelDefinition, FruitDefinition, HexColor, LeafType, SeasonProfileDefinition, TreeForm, TrunkDefinition, VariationDefinition, WindResponseDefinition } from '../definition/types';
1
+ import type { BarkType, BranchLevelDefinition, FruitDefinition, HexColor, LeafType, RootsDefinition, SeasonProfileDefinition, TreeForm, TrunkDefinition, VariationDefinition, WindResponseDefinition } from '../definition/types';
2
2
  /**
3
3
  * A Species' trunk: the shape fields of {@link TrunkDefinition}, without the polygon detail
4
- * (`sides`, `sections`), which the Style chooses. Fields beyond the five required ones (e.g. Stems)
4
+ * (`sides`, `sections`, `flareSections`), which the Style chooses. Fields beyond the five required ones (e.g. Stems)
5
5
  * are optional and default like in a Tree Definition.
6
6
  */
7
- export type SpeciesTrunkDefinition = Pick<TrunkDefinition, 'length' | 'radius' | 'taper' | 'lengthVariation' | 'bend'> & Partial<Omit<TrunkDefinition, 'sides' | 'sections'>>;
7
+ export type SpeciesTrunkDefinition = Pick<TrunkDefinition, 'length' | 'radius' | 'taper' | 'lengthVariation' | 'bend'> & Partial<Omit<TrunkDefinition, 'sides' | 'sections' | 'flareSections'>>;
8
8
  /** A Species' branch level: {@link BranchLevelDefinition} (with its Crown Shape curves) without `sides` / `sections`. */
9
9
  export type SpeciesBranchLevelDefinition = Omit<BranchLevelDefinition, 'sides' | 'sections'>;
10
10
  /** A Species' foliage, Style-neutral: the Style turns it into leaf shape, count, size and texture. */
@@ -34,6 +34,8 @@ export interface SpeciesBarkDefinition {
34
34
  * the Style decides how it is drawn (its shading).
35
35
  */
36
36
  export type SpeciesFruitDefinition = FruitDefinition;
37
+ /** A Species' Roots (ADR 0007): {@link RootsDefinition} without the polygon detail (`sides`, `sections`), which the Style chooses. */
38
+ export type SpeciesRootsDefinition = Omit<RootsDefinition, 'sides' | 'sections'>;
37
39
  /**
38
40
  * Species: a named kind of real tree, described once, Style-neutral (ADR 0005). Plain JSON.
39
41
  * A Style turns it into an ordinary, complete Tree Definition: `createTree(lowPoly.apply(oak), { seed })`.
@@ -53,6 +55,8 @@ export interface SpeciesDefinition {
53
55
  bark: SpeciesBarkDefinition;
54
56
  /** Optional Fruit. */
55
57
  fruit?: SpeciesFruitDefinition;
58
+ /** Optional Roots. */
59
+ roots?: SpeciesRootsDefinition;
56
60
  /** Season Profile (tracks beyond the four required ones are optional and default like in a Tree Definition). */
57
61
  season: Pick<SeasonProfileDefinition, 'leafColor' | 'leafCoverage' | 'blossom' | 'blossomColor'> & Partial<SeasonProfileDefinition>;
58
62
  wind: WindResponseDefinition;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/species/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,QAAQ,EACR,qBAAqB,EACrB,eAAe,EACf,QAAQ,EACR,QAAQ,EACR,uBAAuB,EACvB,QAAQ,EACR,eAAe,EACf,mBAAmB,EACnB,sBAAsB,EACvB,MAAM,qBAAqB,CAAC;AAE7B;;;;GAIG;AACH,MAAM,MAAM,sBAAsB,GAAG,IAAI,CAAC,eAAe,EAAE,QAAQ,GAAG,QAAQ,GAAG,OAAO,GAAG,iBAAiB,GAAG,MAAM,CAAC,GACpH,OAAO,CAAC,IAAI,CAAC,eAAe,EAAE,OAAO,GAAG,UAAU,CAAC,CAAC,CAAC;AAEvD,yHAAyH;AACzH,MAAM,MAAM,4BAA4B,GAAG,IAAI,CAAC,qBAAqB,EAAE,OAAO,GAAG,UAAU,CAAC,CAAC;AAE7F,sGAAsG;AACtG,MAAM,WAAW,wBAAwB;IACvC,iBAAiB;IACjB,IAAI,EAAE,QAAQ,CAAC;IACf,sFAAsF;IACtF,OAAO,EAAE,MAAM,CAAC;IAChB,iFAAiF;IACjF,IAAI,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,aAAa,EAAE,MAAM,CAAC;IACtB,wFAAwF;IACxF,KAAK,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,KAAK,EAAE,MAAM,CAAC;CACf;AAED,sCAAsC;AACtC,MAAM,WAAW,qBAAqB;IACpC,iBAAiB;IACjB,IAAI,EAAE,QAAQ,CAAC;IACf,gDAAgD;IAChD,KAAK,EAAE,QAAQ,CAAC;CACjB;AAED;;;GAG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AAE,mBAAmB,CAAC;CAChC"}
@@ -7,7 +7,8 @@ var trunk = {
7
7
  "radius": .48,
8
8
  "taper": .35,
9
9
  "lengthVariation": .12,
10
- "bend": .14
10
+ "bend": .14,
11
+ "flare": .4
11
12
  };
12
13
  var branches = [
13
14
  {
@@ -93,6 +94,14 @@ var fruit = {
93
94
  "sizeVariation": .15,
94
95
  "hang": .4
95
96
  };
97
+ var roots = {
98
+ "count": 5,
99
+ "length": .2,
100
+ "lengthVariation": .3,
101
+ "radius": .3,
102
+ "angle": 14,
103
+ "bend": .3
104
+ };
96
105
  var season = {
97
106
  "leafColor": [
98
107
  {
@@ -201,10 +210,11 @@ var walnut_default = {
201
210
  foliage,
202
211
  bark,
203
212
  fruit,
213
+ roots,
204
214
  season,
205
215
  wind,
206
216
  variation
207
217
  };
208
- export { bark, branches, walnut_default as default, foliage, form, fruit, id, name, season, trunk, variation, wind };
218
+ export { bark, branches, walnut_default as default, foliage, form, fruit, id, name, roots, season, trunk, variation, wind };
209
219
 
210
220
  //# sourceMappingURL=walnut.js.map
@@ -7,7 +7,8 @@
7
7
  "radius": 0.48,
8
8
  "taper": 0.35,
9
9
  "lengthVariation": 0.12,
10
- "bend": 0.14
10
+ "bend": 0.14,
11
+ "flare": 0.4
11
12
  },
12
13
  "branches": [
13
14
  {
@@ -96,6 +97,14 @@
96
97
  "sizeVariation": 0.15,
97
98
  "hang": 0.4
98
99
  },
100
+ "roots": {
101
+ "count": 5,
102
+ "length": 0.2,
103
+ "lengthVariation": 0.3,
104
+ "radius": 0.3,
105
+ "angle": 14,
106
+ "bend": 0.3
107
+ },
99
108
  "season": {
100
109
  "leafColor": [
101
110
  {
@@ -7,7 +7,8 @@ var trunk = {
7
7
  "radius": .55,
8
8
  "taper": .35,
9
9
  "lengthVariation": .12,
10
- "bend": .18
10
+ "bend": .18,
11
+ "flare": .8
11
12
  };
12
13
  var branches = [
13
14
  {
@@ -86,6 +87,14 @@ var fruit = {
86
87
  "sizeVariation": .2,
87
88
  "hang": .3
88
89
  };
90
+ var roots = {
91
+ "count": 7,
92
+ "length": .3,
93
+ "lengthVariation": .3,
94
+ "radius": .4,
95
+ "angle": 10,
96
+ "bend": .35
97
+ };
89
98
  var season = {
90
99
  "leafColor": [
91
100
  {
@@ -194,10 +203,11 @@ var white_oak_default = {
194
203
  foliage,
195
204
  bark,
196
205
  fruit,
206
+ roots,
197
207
  season,
198
208
  wind,
199
209
  variation
200
210
  };
201
- export { bark, branches, white_oak_default as default, foliage, form, fruit, id, name, season, trunk, variation, wind };
211
+ export { bark, branches, white_oak_default as default, foliage, form, fruit, id, name, roots, season, trunk, variation, wind };
202
212
 
203
213
  //# sourceMappingURL=white-oak.js.map
@@ -7,7 +7,8 @@
7
7
  "radius": 0.55,
8
8
  "taper": 0.35,
9
9
  "lengthVariation": 0.12,
10
- "bend": 0.18
10
+ "bend": 0.18,
11
+ "flare": 0.8
11
12
  },
12
13
  "branches": [
13
14
  {
@@ -92,6 +93,14 @@
92
93
  "sizeVariation": 0.2,
93
94
  "hang": 0.3
94
95
  },
96
+ "roots": {
97
+ "count": 7,
98
+ "length": 0.3,
99
+ "lengthVariation": 0.3,
100
+ "radius": 0.4,
101
+ "angle": 10,
102
+ "bend": 0.35
103
+ },
95
104
  "season": {
96
105
  "leafColor": [
97
106
  {
@@ -1 +1 @@
1
- {"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../src/styles/apply.ts"],"names":[],"mappings":"AAGA,OAAO,EAAqC,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC9F,OAAO,EAOL,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAyB,iBAAiB,EAA4B,MAAM,kBAAkB,CAAC;AAC3G,OAAO,EAAgC,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AA0EvE,+EAA+E;AAC/E,MAAM,MAAM,WAAW,GAAG,iBAAiB,GAAG,cAAc,GAAG,mBAAmB,CAAC;AA4EnF;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,eAAe,GAAG,cAAc,CAI5G"}
1
+ {"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../src/styles/apply.ts"],"names":[],"mappings":"AAGA,OAAO,EAAqC,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC9F,OAAO,EAQL,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAyB,iBAAiB,EAA4B,MAAM,kBAAkB,CAAC;AAC3G,OAAO,EAAgC,KAAK,SAAS,EAAE,MAAM,SAAS,CAAC;AAqFvE,+EAA+E;AAC/E,MAAM,MAAM,WAAW,GAAG,iBAAiB,GAAG,cAAc,GAAG,mBAAmB,CAAC;AA8FnF;;;GAGG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,SAAS,CAAC,EAAE,eAAe,GAAG,cAAc,CAI5G"}
@@ -1,6 +1,6 @@
1
- import { m as coneCurve } from "../names-C6-wuJ29.js";
1
+ import { x as coneCurve } from "../names-BE9he6CS.js";
2
2
  import { t as SEASON_PROFILES } from "../profiles-BAiyeFlh.js";
3
- import { t as applyStyle } from "../apply-CcodnAbs.js";
3
+ import { t as applyStyle } from "../apply-Cio2t7CZ.js";
4
4
  // src/styles/low-poly/index.ts
5
5
  /**
6
6
  * Low-poly broadleaf: a short, stout trunk and a few branches, crowned by faceted foliage
@@ -16,7 +16,8 @@ var broadleaf = {
16
16
  sides: 5,
17
17
  sections: 3,
18
18
  lengthVariation: .15,
19
- bend: .12
19
+ bend: .12,
20
+ flareSections: 2
20
21
  },
21
22
  branches: [{
22
23
  count: 5,
@@ -99,7 +100,8 @@ var conifer = {
99
100
  sides: 5,
100
101
  sections: 4,
101
102
  lengthVariation: .15,
102
- bend: .03
103
+ bend: .03,
104
+ flareSections: 2
103
105
  },
104
106
  branches: [{
105
107
  count: 24,
@@ -1 +1 @@
1
- {"version":3,"file":"low-poly.js","names":[],"sources":["../../src/styles/low-poly/index.ts"],"sourcesContent":["// @casmo/tree.js/styles/low-poly: faceted geometry, flat vertex colours, no image files.\n// Pure data plus `apply` (shared with the other Styles), fetched only when imported.\nimport { coneCurve } from '../../definition/crown-shape';\nimport { CURRENT_SCHEMA_VERSION, type TreeDefinition } from '../../definition/types';\nimport { SEASON_PROFILES } from '../../season/profiles';\nimport { applyStyle } from '../apply';\nimport type { TreeStyle } from '../types';\n\n/**\n * Low-poly broadleaf: a short, stout trunk and a few branches, crowned by faceted foliage\n * clumps. Deciduous Season Profile: fresh green in spring, autumn colours, bare in winter.\n */\nexport const broadleaf: TreeDefinition = {\n schemaVersion: CURRENT_SCHEMA_VERSION,\n name: 'Low-poly broadleaf',\n trunk: { length: 3, radius: 0.22, taper: 0.5, sides: 5, sections: 3, lengthVariation: 0.15, bend: 0.12 },\n branches: [\n { count: 5, start: 0.5, end: 0.92, angle: 42, angleVariation: 0.2, spiral: 137.5, length: 0.5, lengthVariation: 0.2, radius: 0.55, taper: 0.45, sides: 4, sections: 2, bend: 0.12, gravity: 0.15 },\n { count: 3, start: 0.35, end: 1, angle: 38, angleVariation: 0.25, spiral: 120, length: 0.55, lengthVariation: 0.25, radius: 0.6, taper: 0.4, sides: 3, sections: 1, bend: 0.1, gravity: 0.1 },\n ],\n leaves: { count: 2, shape: 'clump', size: 1, sizeVariation: 0.25, start: 0.55, angle: 25 },\n materials: {\n shading: 'flat',\n bark: { color: '#7a5233', roughness: 1, map: null, normalMap: null },\n leaf: { roughness: 1, map: null, alphaTest: 0.5 },\n },\n season: SEASON_PROFILES.deciduous,\n wind: { trunk: 0.15, branches: 0.4, leaves: 0.5, frequency: 1 },\n variation: { color: 0.12, growth: 0.1, season: 0.05 },\n sculpts: [],\n};\n\n/**\n * Low-poly conifer: a straight trunk with drooping whorls that shrink towards the top\n * (a cone Crown Shape), covered in faceted needle tufts. Evergreen Season Profile: it only darkens a little in winter.\n */\nexport const conifer: TreeDefinition = {\n schemaVersion: CURRENT_SCHEMA_VERSION,\n name: 'Low-poly conifer',\n trunk: { length: 5, radius: 0.2, taper: 0.15, sides: 5, sections: 4, lengthVariation: 0.15, bend: 0.03 },\n branches: [\n { count: 24, start: 0.18, end: 0.97, angle: 95, angleVariation: 0.08, spiral: 137.5, length: 0.42, lengthVariation: 0.15, radius: 0.4, taper: 0.3, sides: 3, sections: 2, bend: 0.05, gravity: -0.08,\n // Crown Shape: a cone, full length at the lowest whorl, a tenth of it at the top.\n lengthProfile: coneCurve(0.18) },\n ],\n leaves: { count: 7, shape: 'needle', size: 0.65, sizeVariation: 0.2, start: 0, angle: 35 },\n materials: {\n shading: 'flat',\n bark: { color: '#5c4030', roughness: 1, map: null, normalMap: null },\n leaf: { roughness: 1, map: null, alphaTest: 0.5 },\n },\n season: SEASON_PROFILES.evergreen,\n wind: { trunk: 0.1, branches: 0.3, leaves: 0.3, frequency: 0.8 },\n variation: { color: 0.08, growth: 0.1, season: 0.05 },\n sculpts: [],\n};\n\n/** The low-poly Style. */\nconst lowPoly: TreeStyle = { name: 'low-poly', broadleaf, conifer, apply: (source, overrides) => applyStyle('low-poly', source, overrides) };\nexport default lowPoly;\n"],"mappings":";;;;;;;;AAYA,IAAa,YAA4B;CACvC,eAAA;CACA,MAAM;CACN,OAAO;EAAE,QAAQ;EAAG,QAAQ;EAAM,OAAO;EAAK,OAAO;EAAG,UAAU;EAAG,iBAAiB;EAAM,MAAM;CAAK;CACvG,UAAU,CACR;EAAE,OAAO;EAAG,OAAO;EAAK,KAAK;EAAM,OAAO;EAAI,gBAAgB;EAAK,QAAQ;EAAO,QAAQ;EAAK,iBAAiB;EAAK,QAAQ;EAAM,OAAO;EAAM,OAAO;EAAG,UAAU;EAAG,MAAM;EAAM,SAAS;CAAK,GACjM;EAAE,OAAO;EAAG,OAAO;EAAM,KAAK;E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,UAAU;EAAK,QAAQ;EAAK,WAAW;CAAI;CAC/D,WAAW;EAAE,OAAO;EAAM,QAAQ;EAAK,QAAQ;CAAK;CACpD,SAAS,CAAC;AACZ;;AAGA,IAAM,UAAqB;CAAE,MAAM;CAAY;CAAW;CAAS,QAAQ,QAAQ,cAAc,WAAW,YAAY,QAAQ,SAAS;AAAE"}
1
+ {"version":3,"file":"low-poly.js","names":[],"sources":["../../src/styles/low-poly/index.ts"],"sourcesContent":["// @casmo/tree.js/styles/low-poly: faceted geometry, flat vertex colours, no image files.\n// Pure data plus `apply` (shared with the other Styles), fetched only when imported.\nimport { coneCurve } from '../../definition/crown-shape';\nimport { CURRENT_SCHEMA_VERSION, type TreeDefinition } from '../../definition/types';\nimport { SEASON_PROFILES } from '../../season/profiles';\nimport { applyStyle } from '../apply';\nimport type { TreeStyle } from '../types';\n\n/**\n * Low-poly broadleaf: a short, stout trunk and a few branches, crowned by faceted foliage\n * clumps. Deciduous Season Profile: fresh green in spring, autumn colours, bare in winter.\n */\nexport const broadleaf: TreeDefinition = {\n schemaVersion: CURRENT_SCHEMA_VERSION,\n name: 'Low-poly broadleaf',\n trunk: { length: 3, radius: 0.22, taper: 0.5, sides: 5, sections: 3, lengthVariation: 0.15, bend: 0.12, flareSections: 2 },\n branches: [\n { count: 5, start: 0.5, end: 0.92, angle: 42, angleVariation: 0.2, spiral: 137.5, length: 0.5, lengthVariation: 0.2, radius: 0.55, taper: 0.45, sides: 4, sections: 2, bend: 0.12, gravity: 0.15 },\n { count: 3, start: 0.35, end: 1, angle: 38, angleVariation: 0.25, spiral: 120, length: 0.55, lengthVariation: 0.25, radius: 0.6, taper: 0.4, sides: 3, sections: 1, bend: 0.1, gravity: 0.1 },\n ],\n leaves: { count: 2, shape: 'clump', size: 1, sizeVariation: 0.25, start: 0.55, angle: 25 },\n materials: {\n shading: 'flat',\n bark: { color: '#7a5233', roughness: 1, map: null, normalMap: null },\n leaf: { roughness: 1, map: null, alphaTest: 0.5 },\n },\n season: SEASON_PROFILES.deciduous,\n wind: { trunk: 0.15, branches: 0.4, leaves: 0.5, frequency: 1 },\n variation: { color: 0.12, growth: 0.1, season: 0.05 },\n sculpts: [],\n};\n\n/**\n * Low-poly conifer: a straight trunk with drooping whorls that shrink towards the top\n * (a cone Crown Shape), covered in faceted needle tufts. Evergreen Season Profile: it only darkens a little in winter.\n */\nexport const conifer: TreeDefinition = {\n schemaVersion: CURRENT_SCHEMA_VERSION,\n name: 'Low-poly conifer',\n trunk: { length: 5, radius: 0.2, taper: 0.15, sides: 5, sections: 4, lengthVariation: 0.15, bend: 0.03, flareSections: 2 },\n branches: [\n { count: 24, start: 0.18, end: 0.97, angle: 95, angleVariation: 0.08, spiral: 137.5, length: 0.42, lengthVariation: 0.15, radius: 0.4, taper: 0.3, sides: 3, sections: 2, bend: 0.05, gravity: -0.08,\n // Crown Shape: a cone, full length at the lowest whorl, a tenth of it at the top.\n lengthProfile: coneCurve(0.18) },\n ],\n leaves: { count: 7, shape: 'needle', size: 0.65, sizeVariation: 0.2, start: 0, angle: 35 },\n materials: {\n shading: 'flat',\n bark: { color: '#5c4030', roughness: 1, map: null, normalMap: null },\n leaf: { roughness: 1, map: null, alphaTest: 0.5 },\n },\n season: SEASON_PROFILES.evergreen,\n wind: { trunk: 0.1, branches: 0.3, leaves: 0.3, frequency: 0.8 },\n variation: { color: 0.08, growth: 0.1, season: 0.05 },\n sculpts: [],\n};\n\n/** The low-poly Style. */\nconst lowPoly: TreeStyle = { name: 'low-poly', broadleaf, conifer, apply: (source, overrides) => applyStyle('low-poly', source, overrides) };\nexport default lowPoly;\n"],"mappings":";;;;;;;;AAYA,IAAa,YAA4B;CACvC,eAAA;CACA,MAAM;CACN,OAAO;EAAE,QAAQ;EAAG,QAAQ;EAAM,OAAO;EAAK,OAAO;EAAG,UAAU;EAAG,iBAAiB;EAAM,MAAM;EAAM,eAAe;CAAE;CACzH,UAAU,CACR;EAAE,OAAO;EAAG,OAAO;EAAK,KAAK;EAAM,OA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F,WAAW;EACT,SAAS;EACT,MAAM;GAAE,OAAO;GAAW,WAAW;GAAG,KAAK;GAAM,WAAW;EAAK;EACnE,MAAM;GAAE,WAAW;GAAG,KAAK;GAAM,WAAW;EAAI;CAClD;CACA,QAAQ,gBAAgB;CACxB,MAAM;EAAE,OAAO;EAAK,UAAU;EAAK,QAAQ;EAAK,WAAW;CAAI;CAC/D,WAAW;EAAE,OAAO;EAAM,QAAQ;EAAK,QAAQ;CAAK;CACpD,SAAS,CAAC;AACZ;;AAGA,IAAM,UAAqB;CAAE,MAAM;CAAY;CAAW;CAAS,QAAQ,QAAQ,cAAc,WAAW,YAAY,QAAQ,SAAS;AAAE"}
@@ -0,0 +1,27 @@
1
+ import type { MaterialFeatures, TreeDefinition, TreeDefinitionInput } from '../definition/types';
2
+ import type { StyleName } from './names';
3
+ /**
4
+ * Suggested Material Features for each built-in Style (like `SUGGESTED_TREE_EFFECTS`). Nothing uses
5
+ * them by default; pass one to {@link withMaterialFeatures} to opt a Definition in.
6
+ *
7
+ * Tuned against the e2e screenshots (e2e/material-features.spec.ts). Structural Occlusion only darkens
8
+ * ambient light, so it is set high; translucency stays low enough that a crown against the sun keeps its shape.
9
+ */
10
+ export declare const SUGGESTED_MATERIAL_FEATURES: Record<StyleName, MaterialFeatures>;
11
+ /**
12
+ * The Material Features a Tree Definition has (`materials.leaf.crownNormals`, `materials.leaf.translucency`,
13
+ * `materials.occlusion`), in the shape {@link withMaterialFeatures} takes. A feature that is absent is left
14
+ * out; the values are the Definition's own (not copies).
15
+ */
16
+ export declare function materialFeaturesOf(definition: TreeDefinition): MaterialFeatures;
17
+ /**
18
+ * Returns a new Tree Definition whose Material Features are exactly `features`: each feature given is
19
+ * set, each feature left out is switched off (`{}` switches them all off). Everything else is kept. The
20
+ * input is not changed. Throws a TreeDefinitionError for an out-of-range value.
21
+ *
22
+ * ```ts
23
+ * const tree = createTree(withMaterialFeatures(stylized.broadleaf, SUGGESTED_MATERIAL_FEATURES.stylized));
24
+ * ```
25
+ */
26
+ export declare function withMaterialFeatures(definition: TreeDefinition | TreeDefinitionInput, features: MaterialFeatures): TreeDefinition;
27
+ //# sourceMappingURL=material-features.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"material-features.d.ts","sourceRoot":"","sources":["../../src/styles/material-features.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AACjG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC;;;;;;GAMG;AACH,eAAO,MAAM,2BAA2B,EAAE,MAAM,CAAC,SAAS,EAAE,gBAAgB,CAkB3E,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,cAAc,GAAG,gBAAgB,CAQ/E;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,cAAc,GAAG,mBAAmB,EAAE,QAAQ,EAAE,gBAAgB,GAAG,cAAc,CAqBjI"}
@@ -1,6 +1,6 @@
1
- import { m as coneCurve } from "../names-C6-wuJ29.js";
1
+ import { x as coneCurve } from "../names-BE9he6CS.js";
2
2
  import { t as SEASON_PROFILES } from "../profiles-BAiyeFlh.js";
3
- import { i as TEXTURES, n as BARK_TEXTURES, r as LEAF_TEXTURES, t as applyStyle } from "../apply-CcodnAbs.js";
3
+ import { i as TEXTURES, n as BARK_TEXTURES, r as LEAF_TEXTURES, t as applyStyle } from "../apply-Cio2t7CZ.js";
4
4
  // src/styles/realistic/index.ts
5
5
  /**
6
6
  * Realistic broadleaf: a tall, slightly leaning trunk with three branching levels and many
@@ -16,7 +16,8 @@ var broadleaf = {
16
16
  sides: 12,
17
17
  sections: 10,
18
18
  lengthVariation: .15,
19
- bend: .1
19
+ bend: .1,
20
+ flareSections: 3
20
21
  },
21
22
  branches: [
22
23
  {
@@ -118,7 +119,8 @@ var conifer = {
118
119
  sides: 10,
119
120
  sections: 10,
120
121
  lengthVariation: .12,
121
- bend: .03
122
+ bend: .03,
123
+ flareSections: 3
122
124
  },
123
125
  branches: [{
124
126
  count: 34,
@@ -1 +1 @@
1
- {"version":3,"file":"realistic.js","names":[],"sources":["../../src/styles/realistic/index.ts"],"sourcesContent":["// @casmo/tree.js/styles/realistic: smooth PBR shading, textured bark and alpha-cut leaf cards.\n// Pure data plus `apply` (shared with the other Styles), fetched only when imported.\n// The textures are separate files (dist/textures/realistic/*.png, made by scripts/generate-textures.mjs),\n// referenced by relative URLs that resolve against the texture base path (`setTextureOptions`,\n// or `createTree(definition, { textures: { basePath } })`), so an app can host them on its own CDN.\nimport { coneCurve } from '../../definition/crown-shape';\nimport { CURRENT_SCHEMA_VERSION, type TreeDefinition } from '../../definition/types';\nimport { SEASON_PROFILES } from '../../season/profiles';\nimport { applyStyle } from '../apply';\nimport type { TreeStyle } from '../types';\nimport { BARK_TEXTURES, LEAF_TEXTURES, TEXTURES } from './textures';\n\nexport { BARK_TEXTURES, LEAF_TEXTURES, TEXTURES };\n\n/**\n * Realistic broadleaf: a tall, slightly leaning trunk with three branching levels and many\n * leaf-spray cards. Deciduous Season Profile: fresh green in spring, autumn colours, bare in winter.\n */\nexport const broadleaf: TreeDefinition = {\n schemaVersion: CURRENT_SCHEMA_VERSION,\n name: 'Realistic broadleaf',\n trunk: { length: 5, radius: 0.28, taper: 0.35, sides: 12, sections: 10, lengthVariation: 0.15, bend: 0.1 },\n branches: [\n { count: 8, start: 0.4, end: 0.95, angle: 48, angleVariation: 0.2, spiral: 137.5, length: 0.5, lengthVariation: 0.2, radius: 0.5, taper: 0.5, sides: 8, sections: 6, bend: 0.15, gravity: 0.05 },\n { count: 5, start: 0.25, end: 1, angle: 40, angleVariation: 0.25, spiral: 120, length: 0.5, lengthVariation: 0.25, radius: 0.55, taper: 0.5, sides: 5, sections: 4, bend: 0.15, gravity: 0.1 },\n { count: 3, start: 0.3, end: 1, angle: 35, angleVariation: 0.3, spiral: 140, length: 0.5, lengthVariation: 0.3, radius: 0.6, taper: 0.5, sides: 3, sections: 2, bend: 0.1, gravity: 0.15 },\n ],\n leaves: { count: 6, shape: 'card', size: 0.7, sizeVariation: 0.25, start: 0.2, angle: 45 },\n materials: {\n shading: 'standard',\n bark: { color: '#c9bba8', roughness: 0.95, map: TEXTURES.bark, normalMap: TEXTURES.barkNormal },\n leaf: { roughness: 0.65, map: TEXTURES.leaf, alphaTest: 0.4 },\n },\n season: SEASON_PROFILES.deciduous,\n wind: { trunk: 0.15, branches: 0.45, leaves: 0.8, frequency: 1 },\n variation: { color: 0.1, growth: 0.1, season: 0.05 },\n sculpts: [],\n};\n\n/**\n * Realistic conifer: a straight trunk with dense, drooping whorls that shrink towards the top\n * (a cone Crown Shape), covered in needle-spray cards. Evergreen Season Profile.\n */\nexport const conifer: TreeDefinition = {\n schemaVersion: CURRENT_SCHEMA_VERSION,\n name: 'Realistic conifer',\n trunk: { length: 7, radius: 0.24, taper: 0.08, sides: 10, sections: 10, lengthVariation: 0.12, bend: 0.03 },\n branches: [\n { count: 34, start: 0.12, end: 0.97, angle: 88, angleVariation: 0.1, spiral: 137.5, length: 0.38, lengthVariation: 0.15, radius: 0.22, taper: 0.25, sides: 5, sections: 4, bend: 0.08, gravity: 0.12,\n // Crown Shape: a cone, full length at the lowest whorl, a tenth of it at the top.\n lengthProfile: coneCurve(0.12) },\n { count: 6, start: 0.15, end: 1, angle: 55, angleVariation: 0.2, spiral: 180, length: 0.45, lengthVariation: 0.2, radius: 0.5, taper: 0.4, sides: 3, sections: 2, bend: 0.05, gravity: 0.1 },\n ],\n leaves: { count: 8, shape: 'card', size: 0.8, sizeVariation: 0.2, start: 0, angle: 35 },\n materials: {\n shading: 'standard',\n bark: { color: '#b0a090', roughness: 0.95, map: TEXTURES.bark, normalMap: TEXTURES.barkNormal },\n leaf: { roughness: 0.7, map: TEXTURES.needles, alphaTest: 0.4 },\n },\n season: SEASON_PROFILES.evergreen,\n wind: { trunk: 0.08, branches: 0.3, leaves: 0.4, frequency: 0.8 },\n variation: { color: 0.08, growth: 0.1, season: 0.05 },\n sculpts: [],\n};\n\n/** The realistic Style. */\nconst realistic: TreeStyle = { name: 'realistic', broadleaf, conifer, apply: (source, overrides) => applyStyle('realistic', source, overrides) };\nexport default realistic;\n"],"mappings":";;;;;;;;AAkBA,IAAa,YAA4B;CACvC,eAAA;CACA,MAAM;CACN,OAAO;EAAE,QAAQ;EAAG,QAAQ;EAAM,OAAO;EAAM,OAAO;EAAI,UAAU;EAAI,iBAAiB;EAAM,MAAM;CAAI;CACzG,UAAU;EACR;GAAE,OAAO;GAAG,OAAO;GAAK,KAAK;GAAM,OAAO;GAAI,gBAAgB;GAAK,QAAQ;GAAO,QAAQ;GAAK,iBAAiB;GAAK,QAAQ;GAAK,OAAO;GAAK,OAAO;GAAG,UAAU;GAAG,MAAM;GAAM,SAAS;EAAK;EAC/L;GAAE,OAAO;GAAG,OAAO;GAAM,KAAK;GAAG,OAAO;GAAI,gBAAgB;GAAM,QAAQ;GAAK,QAAQ;GAAK,iBAAiB;GAAM,QAAQ;GAAM,OAAO;GAAK,OAAO;GAAG,UAAU;GAAG,MAAM;GAAM,SAAS;EAAI;EAC7L;GAAE,OAAO;GAAG,OAAO;GAAK,KAAK;GAAG,OAAO;GAAI,gBAAgB;GAAK,QAAQ;GAAK,QAAQ;GAAK,iBAAiB;GAAK,QAAQ;GAAK,OAAO;GAAK,OAAO;GAAG,UAAU;GAAG,MAAM;GAAK,SAAS;EAAK;CAC3L;CACA,QAAQ;EAAE,OAAO;EAAG,OAAO;EAAQ,MAAM;EAAK,eAAe;EAAM,OAAO;EAAK,OAAO;CAAG;CACzF,WAAW;EACT,SAAS;EACT,MAAM;GAAE,OAAO;GAAW,WAAW;GAAM,KAAK,SAAS;GAAM,WAAW,SAAS;EAAW;EAC9F,MAAM;GAAE,WAAW;GAAM,KAAK,SAAS;GAAM,WAAW;EAAI;CAC9D;CACA,QAAQ,gBAAgB;CACxB,MAAM;EAAE,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AE"}
1
+ {"version":3,"file":"realistic.js","names":[],"sources":["../../src/styles/realistic/index.ts"],"sourcesContent":["// @casmo/tree.js/styles/realistic: smooth PBR shading, textured bark and alpha-cut leaf cards.\n// Pure data plus `apply` (shared with the other Styles), fetched only when imported.\n// The textures are separate files (dist/textures/realistic/*.png, made by scripts/generate-textures.mjs),\n// referenced by relative URLs that resolve against the texture base path (`setTextureOptions`,\n// or `createTree(definition, { textures: { basePath } })`), so an app can host them on its own CDN.\nimport { coneCurve } from '../../definition/crown-shape';\nimport { CURRENT_SCHEMA_VERSION, type TreeDefinition } from '../../definition/types';\nimport { SEASON_PROFILES } from '../../season/profiles';\nimport { applyStyle } from '../apply';\nimport type { TreeStyle } from '../types';\nimport { BARK_TEXTURES, LEAF_TEXTURES, TEXTURES } from './textures';\n\nexport { BARK_TEXTURES, LEAF_TEXTURES, TEXTURES };\n\n/**\n * Realistic broadleaf: a tall, slightly leaning trunk with three branching levels and many\n * leaf-spray cards. Deciduous Season Profile: fresh green in spring, autumn colours, bare in winter.\n */\nexport const broadleaf: TreeDefinition = {\n schemaVersion: CURRENT_SCHEMA_VERSION,\n name: 'Realistic broadleaf',\n trunk: { length: 5, radius: 0.28, taper: 0.35, sides: 12, sections: 10, lengthVariation: 0.15, bend: 0.1, flareSections: 3 },\n branches: [\n { count: 8, start: 0.4, end: 0.95, angle: 48, angleVariation: 0.2, spiral: 137.5, length: 0.5, lengthVariation: 0.2, radius: 0.5, taper: 0.5, sides: 8, sections: 6, bend: 0.15, gravity: 0.05 },\n { count: 5, start: 0.25, end: 1, angle: 40, angleVariation: 0.25, spiral: 120, length: 0.5, lengthVariation: 0.25, radius: 0.55, taper: 0.5, sides: 5, sections: 4, bend: 0.15, gravity: 0.1 },\n { count: 3, start: 0.3, end: 1, angle: 35, angleVariation: 0.3, spiral: 140, length: 0.5, lengthVariation: 0.3, radius: 0.6, taper: 0.5, sides: 3, sections: 2, bend: 0.1, gravity: 0.15 },\n ],\n leaves: { count: 6, shape: 'card', size: 0.7, sizeVariation: 0.25, start: 0.2, angle: 45 },\n materials: {\n shading: 'standard',\n bark: { color: '#c9bba8', roughness: 0.95, map: TEXTURES.bark, normalMap: TEXTURES.barkNormal },\n leaf: { roughness: 0.65, map: TEXTURES.leaf, alphaTest: 0.4 },\n },\n season: SEASON_PROFILES.deciduous,\n wind: { trunk: 0.15, branches: 0.45, leaves: 0.8, frequency: 1 },\n variation: { color: 0.1, growth: 0.1, season: 0.05 },\n sculpts: [],\n};\n\n/**\n * Realistic conifer: a straight trunk with dense, drooping whorls that shrink towards the top\n * (a cone Crown Shape), covered in needle-spray cards. Evergreen Season Profile.\n */\nexport const conifer: TreeDefinition = {\n schemaVersion: CURRENT_SCHEMA_VERSION,\n name: 'Realistic conifer',\n trunk: { length: 7, radius: 0.24, taper: 0.08, sides: 10, sections: 10, lengthVariation: 0.12, bend: 0.03, flareSections: 3 },\n branches: [\n { count: 34, start: 0.12, end: 0.97, angle: 88, angleVariation: 0.1, spiral: 137.5, length: 0.38, lengthVariation: 0.15, radius: 0.22, taper: 0.25, sides: 5, sections: 4, bend: 0.08, gravity: 0.12,\n // Crown Shape: a cone, full length at the lowest whorl, a tenth of it at the top.\n lengthProfile: coneCurve(0.12) },\n { count: 6, start: 0.15, end: 1, angle: 55, angleVariation: 0.2, spiral: 180, length: 0.45, lengthVariation: 0.2, radius: 0.5, taper: 0.4, sides: 3, sections: 2, bend: 0.05, gravity: 0.1 },\n ],\n leaves: { count: 8, shape: 'card', size: 0.8, sizeVariation: 0.2, start: 0, angle: 35 },\n materials: {\n shading: 'standard',\n bark: { color: '#b0a090', roughness: 0.95, map: TEXTURES.bark, normalMap: TEXTURES.barkNormal },\n leaf: { roughness: 0.7, map: TEXTURES.needles, alphaTest: 0.4 },\n },\n season: SEASON_PROFILES.evergreen,\n wind: { trunk: 0.08, branches: 0.3, leaves: 0.4, frequency: 0.8 },\n variation: { color: 0.08, growth: 0.1, season: 0.05 },\n sculpts: [],\n};\n\n/** The realistic Style. */\nconst realistic: TreeStyle = { name: 'realistic', broadleaf, conifer, apply: (source, overrides) => applyStyle('realistic', source, overrides) };\nexport default realistic;\n"],"mappings":";;;;;;;;AAkBA,IAAa,YAA4B;CACvC,eAAA;CACA,MAAM;CACN,OAAO;EAAE,QAAQ;EAAG,QAAQ;EAAM,OAAO;EAAM,OAAO;EAAI,UAAU;EAAI,iBAAiB;EAAM,MAAM;EAAK,eAAe;CAAE;CAC3H,UAAU;EACR;GAAE,OAAO;GAAG,OAAO;GAAK,KAAK;GAAM,OAAO;GAAI,gBAAgB;GAAK,QAAQ;GAAO,QAAQ;GAAK,iBAAiB;GAAK,QAAQ;GAAK,OAAO;GAAK,OAAO;GAAG,UAAU;GAAG,MAAM;GAAM,SAAS;EAAK;EAC/L;GAAE,OAAO;GAAG,OAAO;GAAM,KAAK;GAAG,OAAO;GAAI,gBAAgB;GAAM,QAAQ;GAAK,QAAQ;GAAK,iBAAiB;GAAM,QAAQ;GAAM,OAAO;GAAK,OAAO;GAAG,UAAU;GAAG,MAAM;GAAM,SAAS;EAAI;EAC7L;GAAE,OAAO;GAAG,OAAO;GAAK,KAAK;GAAG,OAAO;GAAI,gBAAgB;GAAK,QAAQ;GAAK,QAAQ;GAAK,iBAAiB;GAAK,QAAQ;GAAK,OAAO;GAAK,OAAO;GAAG,UAAU;GAAG,MAAM;GAAK,SAAS;EAAK;CAC3L;CACA,QAAQ;EAAE,OAAO;EAAG,OAAO;EAAQ,MAAM;EAAK,eAAe;EAAM,OAAO;EAAK,OAAO;CAAG;CACzF,WAAW;EACT,SAAS;EACT,MAAM;GAAE,OAAO;GAAW,WAAW;GAAM,KAAK,SAAS;GAAM,WAAW,SAAS;EAAW;EAC9F,MAAM;GAAE,WAAW;GAAM,KAAK,SAAS;GAAM,WAAW;EAAI;CAC9D;CACA,QAAQ,gBAAgB;CACxB,MAAM;EAAE,OAAO;EAAM,UAAU;EAAM,QAAQ;EAAK,WAAW;CAAE;CAC/D,WAAW;EAAE,OAAO;E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+ import { x as coneCurve } from "../names-BE9he6CS.js";
2
2
  import { t as SEASON_PROFILES } from "../profiles-BAiyeFlh.js";
3
- import { t as applyStyle } from "../apply-CcodnAbs.js";
3
+ import { t as applyStyle } from "../apply-Cio2t7CZ.js";
4
4
  // src/styles/stylized/index.ts
5
5
  /**
6
6
  * Deciduous with blossom: bright, saturated colours for the toon look. Pink blossom covers
@@ -116,7 +116,8 @@ var broadleaf = {
116
116
  sides: 10,
117
117
  sections: 8,
118
118
  lengthVariation: .15,
119
- bend: .25
119
+ bend: .25,
120
+ flareSections: 3
120
121
  },
121
122
  branches: [{
122
123
  count: 6,
@@ -200,7 +201,8 @@ var conifer = {
200
201
  sides: 8,
201
202
  sections: 6,
202
203
  lengthVariation: .15,
203
- bend: .05
204
+ bend: .05,
205
+ flareSections: 3
204
206
  },
205
207
  branches: [{
206
208
  count: 18,
@@ -1 +1 @@
1
- {"version":3,"file":"stylized.js","names":[],"sources":["../../src/styles/stylized/index.ts"],"sourcesContent":["// @casmo/tree.js/styles/stylized: soft toon shading, rounded leaf clumps, blossom in early spring, no image files.\n// Pure data plus `apply` (shared with the other Styles), fetched only when imported.\nimport { coneCurve } from '../../definition/crown-shape';\nimport { CURRENT_SCHEMA_VERSION, type SeasonProfileDefinition, type TreeDefinition } from '../../definition/types';\nimport { SEASON_PROFILES } from '../../season/profiles';\nimport { applyStyle } from '../apply';\nimport type { TreeStyle } from '../types';\n\n/**\n * Deciduous with blossom: bright, saturated colours for the toon look. Pink blossom covers\n * most of the crown in early spring (Season 0 .. ~0.12, opening in the last days of winter),\n * then the leaves take over: fresh green, summer green, orange and red, bare in winter.\n * Drop the blossom with `extendDefinition(broadleaf, { season: { blossom: [{ t: 0, value: 0 }] } })`.\n */\nconst blossoming: SeasonProfileDefinition = {\n leafColor: [\n { t: 0, value: '#a5d65a' },\n { t: 0.2, value: '#55a83c' },\n { t: 0.5, value: '#55a83c' },\n { t: 0.58, value: '#f0a530' },\n { t: 0.68, value: '#d9502e' },\n { t: 0.97, value: '#d9502e' },\n { t: 1, value: '#a5d65a' },\n ],\n leafCoverage: SEASON_PROFILES.deciduous.leafCoverage,\n blossom: [\n { t: 0, value: 0.75 },\n { t: 0.08, value: 0.75 },\n { t: 0.15, value: 0 },\n { t: 0.95, value: 0 },\n { t: 1, value: 0.75 },\n ],\n blossomColor: '#ffb3d1',\n};\n\n/** Evergreen in toon colours: full all year, a little darker in winter. */\nconst evergreen: SeasonProfileDefinition = {\n leafColor: [\n { t: 0, value: '#4f9a4a' },\n { t: 0.25, value: '#3c8a45' },\n { t: 0.55, value: '#3c8a45' },\n { t: 0.75, value: '#2e6b40' },\n { t: 0.92, value: '#2e6b40' },\n { t: 1, value: '#4f9a4a' },\n ],\n leafCoverage: [{ t: 0, value: 1 }],\n blossom: [{ t: 0, value: 0 }],\n blossomColor: '#ffb3d1',\n};\n\n/**\n * Stylized broadleaf: a curvy trunk with a round crown of big, soft foliage clumps.\n * Flowers pink in early spring, then follows the deciduous year.\n */\nexport const broadleaf: TreeDefinition = {\n schemaVersion: CURRENT_SCHEMA_VERSION,\n name: 'Stylized broadleaf',\n trunk: { length: 3.2, radius: 0.24, taper: 0.55, sides: 10, sections: 8, lengthVariation: 0.15, bend: 0.25 },\n branches: [\n { count: 6, start: 0.45, end: 0.9, angle: 48, angleVariation: 0.2, spiral: 137.5, length: 0.5, lengthVariation: 0.2, radius: 0.55, taper: 0.5, sides: 8, sections: 5, bend: 0.25, gravity: 0.05 },\n { count: 3, start: 0.4, end: 1, angle: 40, angleVariation: 0.25, spiral: 120, length: 0.5, lengthVariation: 0.25, radius: 0.6, taper: 0.45, sides: 6, sections: 3, bend: 0.2, gravity: 0 },\n ],\n leaves: { count: 2, shape: 'puff', size: 1.1, sizeVariation: 0.3, start: 0.6, angle: 30 },\n materials: {\n shading: 'toon',\n bark: { color: '#8a5a3b', roughness: 1, map: null, normalMap: null },\n leaf: { roughness: 1, map: null, alphaTest: 0.5 },\n },\n season: blossoming,\n wind: { trunk: 0.15, branches: 0.45, leaves: 0.6, frequency: 1 },\n variation: { color: 0.1, growth: 0.1, season: 0.05 },\n sculpts: [],\n};\n\n/**\n * Stylized conifer: a straight trunk with soft, upturned whorls that shrink towards the top\n * (a cone Crown Shape), each carrying a few rounded clumps, so the tree reads as a stack of puffs.\n * Evergreen: it only darkens a little in winter.\n */\nexport const conifer: TreeDefinition = {\n schemaVersion: CURRENT_SCHEMA_VERSION,\n name: 'Stylized conifer',\n trunk: { length: 5, radius: 0.2, taper: 0.2, sides: 8, sections: 6, lengthVariation: 0.15, bend: 0.05 },\n branches: [\n { count: 18, start: 0.15, end: 0.97, angle: 85, angleVariation: 0.1, spiral: 137.5, length: 0.5, lengthVariation: 0.1, radius: 0.4, taper: 0.35, sides: 5, sections: 3, bend: 0.1, gravity: 0.05,\n // Crown Shape: a cone, full length at the lowest whorl, a tenth of it at the top.\n lengthProfile: coneCurve(0.15) },\n ],\n leaves: { count: 4, shape: 'puff', size: 0.6, sizeVariation: 0.2, start: 0.1, angle: 20 },\n materials: {\n shading: 'toon',\n bark: { color: '#6e4a35', roughness: 1, map: null, normalMap: null },\n leaf: { roughness: 1, map: null, alphaTest: 0.5 },\n },\n season: evergreen,\n wind: { trunk: 0.1, branches: 0.3, leaves: 0.4, frequency: 0.8 },\n variation: { color: 0.08, growth: 0.1, season: 0.05 },\n sculpts: [],\n};\n\n/** The stylized Style. */\nconst stylized: TreeStyle = { name: 'stylized', broadleaf, conifer, apply: (source, overrides) => applyStyle('stylized', source, overrides) };\nexport default stylized;\n"],"mappings":";;;;;;;;;;AAcA,IAAM,aAAsC;CAC1C,WAAW;EACT;GAAE,GAAG;GAAG,OAAO;EAAU;EACzB;GAAE,GAAG;GAAK,OAAO;EAAU;EAC3B;GAAE,GAAG;GAAK,OAAO;EAAU;EAC3B;GAAE,GAAG;GAAM,OAAO;EAAU;EAC5B;GAAE,GAAG;GAAM,OAAO;EAAU;EAC5B;GAAE,GAAG;GAAM,OAAO;EAAU;EAC5B;GAAE,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AW,YAAY,QAAQ,SAAS;AAAE"}
1
+ {"version":3,"file":"stylized.js","names":[],"sources":["../../src/styles/stylized/index.ts"],"sourcesContent":["// @casmo/tree.js/styles/stylized: soft toon shading, rounded leaf clumps, blossom in early spring, no image files.\n// Pure data plus `apply` (shared with the other Styles), fetched only when imported.\nimport { coneCurve } from '../../definition/crown-shape';\nimport { CURRENT_SCHEMA_VERSION, type SeasonProfileDefinition, type TreeDefinition } from '../../definition/types';\nimport { SEASON_PROFILES } from '../../season/profiles';\nimport { applyStyle } from '../apply';\nimport type { TreeStyle } from '../types';\n\n/**\n * Deciduous with blossom: bright, saturated colours for the toon look. Pink blossom covers\n * most of the crown in early spring (Season 0 .. ~0.12, opening in the last days of winter),\n * then the leaves take over: fresh green, summer green, orange and red, bare in winter.\n * Drop the blossom with `extendDefinition(broadleaf, { season: { blossom: [{ t: 0, value: 0 }] } })`.\n */\nconst blossoming: SeasonProfileDefinition = {\n leafColor: [\n { t: 0, value: '#a5d65a' },\n { t: 0.2, value: '#55a83c' },\n { t: 0.5, value: '#55a83c' },\n { t: 0.58, value: '#f0a530' },\n { t: 0.68, value: '#d9502e' },\n { t: 0.97, value: '#d9502e' },\n { t: 1, value: '#a5d65a' },\n ],\n leafCoverage: SEASON_PROFILES.deciduous.leafCoverage,\n blossom: [\n { t: 0, value: 0.75 },\n { t: 0.08, value: 0.75 },\n { t: 0.15, value: 0 },\n { t: 0.95, value: 0 },\n { t: 1, value: 0.75 },\n ],\n blossomColor: '#ffb3d1',\n};\n\n/** Evergreen in toon colours: full all year, a little darker in winter. */\nconst evergreen: SeasonProfileDefinition = {\n leafColor: [\n { t: 0, value: '#4f9a4a' },\n { t: 0.25, value: '#3c8a45' },\n { t: 0.55, value: '#3c8a45' },\n { t: 0.75, value: '#2e6b40' },\n { t: 0.92, value: '#2e6b40' },\n { t: 1, value: '#4f9a4a' },\n ],\n leafCoverage: [{ t: 0, value: 1 }],\n blossom: [{ t: 0, value: 0 }],\n blossomColor: '#ffb3d1',\n};\n\n/**\n * Stylized broadleaf: a curvy trunk with a round crown of big, soft foliage clumps.\n * Flowers pink in early spring, then follows the deciduous year.\n */\nexport const broadleaf: TreeDefinition = {\n schemaVersion: CURRENT_SCHEMA_VERSION,\n name: 'Stylized broadleaf',\n trunk: { length: 3.2, radius: 0.24, taper: 0.55, sides: 10, sections: 8, lengthVariation: 0.15, bend: 0.25, flareSections: 3 },\n branches: [\n { count: 6, start: 0.45, end: 0.9, angle: 48, angleVariation: 0.2, spiral: 137.5, length: 0.5, lengthVariation: 0.2, radius: 0.55, taper: 0.5, sides: 8, sections: 5, bend: 0.25, gravity: 0.05 },\n { count: 3, start: 0.4, end: 1, angle: 40, angleVariation: 0.25, spiral: 120, length: 0.5, lengthVariation: 0.25, radius: 0.6, taper: 0.45, sides: 6, sections: 3, bend: 0.2, gravity: 0 },\n ],\n leaves: { count: 2, shape: 'puff', size: 1.1, sizeVariation: 0.3, start: 0.6, angle: 30 },\n materials: {\n shading: 'toon',\n bark: { color: '#8a5a3b', roughness: 1, map: null, normalMap: null },\n leaf: { roughness: 1, map: null, alphaTest: 0.5 },\n },\n season: blossoming,\n wind: { trunk: 0.15, branches: 0.45, leaves: 0.6, frequency: 1 },\n variation: { color: 0.1, growth: 0.1, season: 0.05 },\n sculpts: [],\n};\n\n/**\n * Stylized conifer: a straight trunk with soft, upturned whorls that shrink towards the top\n * (a cone Crown Shape), each carrying a few rounded clumps, so the tree reads as a stack of puffs.\n * Evergreen: it only darkens a little in winter.\n */\nexport const conifer: TreeDefinition = {\n schemaVersion: CURRENT_SCHEMA_VERSION,\n name: 'Stylized conifer',\n trunk: { length: 5, radius: 0.2, taper: 0.2, sides: 8, sections: 6, lengthVariation: 0.15, bend: 0.05, flareSections: 3 },\n branches: [\n { count: 18, start: 0.15, end: 0.97, angle: 85, angleVariation: 0.1, spiral: 137.5, length: 0.5, lengthVariation: 0.1, radius: 0.4, taper: 0.35, sides: 5, sections: 3, bend: 0.1, gravity: 0.05,\n // Crown Shape: a cone, full length at the lowest whorl, a tenth of it at the top.\n lengthProfile: coneCurve(0.15) },\n ],\n leaves: { count: 4, shape: 'puff', size: 0.6, sizeVariation: 0.2, start: 0.1, angle: 20 },\n materials: {\n shading: 'toon',\n bark: { color: '#6e4a35', roughness: 1, map: null, normalMap: null },\n leaf: { roughness: 1, map: null, alphaTest: 0.5 },\n },\n season: evergreen,\n wind: { trunk: 0.1, branches: 0.3, leaves: 0.4, frequency: 0.8 },\n variation: { color: 0.08, growth: 0.1, season: 0.05 },\n sculpts: [],\n};\n\n/** The stylized Style. */\nconst stylized: TreeStyle = { name: 'stylized', broadleaf, conifer, apply: (source, overrides) => applyStyle('stylized', source, overrides) };\nexport default stylized;\n"],"mappings":";;;;;;;;;;AAcA,IAAM,aAAsC;CAC1C,WAAW;EACT;GAAE,GAAG;GAAG,OAAO;EAAU;EACzB;GAAE,GAAG;GAAK,OAAO;EAAU;EAC3B;GAAE,GAAG;GAAK,OAAO;EAAU;EAC3B;GAAE,GAAG;GAAM,OAAO;EAAU;EAC5B;GAAE,GAAG;GAAM,OAAO;EAAU;EAC5B;GAAE,GAAG;GAAM,OAAO;EAAU;EAC5B;GAAE,GAAG;GAAG,OAAO;EAAU;CAC3B;CACA,cAAc,gBAAgB,UAAU;CACxC,SAAS;EACP;GAAE,GAAG;GAAG,OAAO;EAAK;EACpB;GAAE,GAAG;GAAM,OAAO;EAAK;EACvB;GAAE,GAAG;GAAM,OAAO;EAAE;EACpB;GAAE,GAAG;GAAM,OAAO;EAAE;EACpB;GAAE,GAAG;GAAG,OAAO;EAAK;CACtB;CACA,cAAc;AAChB;;AAGA,IAAM,YAAqC;CACzC,WAAW;EACT;GAAE,GAAG;GAAG,OAAO;EAAU;EACzB;GAAE,GAAG;GAAM,OAAO;EAAU;EAC5B;GAAE,GAAG;GAAM,OAAO;EAAU;EAC5B;GAAE,GAAG;GAAM,OAAO;EAAU;EAC5B;GAAE,GAAG;GAAM,OAAO;EAAU;EAC5B;GAAE,G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,UAAU;EAAG,iBAAiB;EAAM,MAAM;EAAM,eAAe;CAAE;CACxH,UAAU,CACR;EAAE,OAAO;EAAI,OAAO;EAAM,KAAK;EAAM,OAAO;EAAI,gBAAgB;EAAK,QAAQ;EAAO,QAAQ;EAAK,iBAAiB;EAAK,QAAQ;EAAK,OAAO;EAAM,OAAO;EAAG,UAAU;EAAG,MAAM;EAAK,SAAS;EAE1L,eAAe,UAAU,GAAI;CAAE,CACnC;CACA,QAAQ;EAAE,OAAO;EAAG,OAAO;EAAQ,MAAM;EAAK,eAAe;EAAK,OAAO;EAAK,OAAO;CAAG;CACxF,WAAW;EACT,SAAS;EACT,MAAM;GAAE,OAAO;GAAW,WAAW;GAAG,KAAK;GAAM,WAAW;EAAK;EACnE,MAAM;GAAE,WAAW;GAAG,KAAK;GAAM,WAAW;EAAI;CAClD;CACA,QAAQ;CACR,MAAM;EAAE,OAAO;EAAK,UAAU;EAAK,QAAQ;EAAK,WAAW;CAAI;CAC/D,WAAW;EAAE,OAAO;EAAM,QAAQ;EAAK,QAAQ;CAAK;CACpD,SAAS,CAAC;AACZ;;AAGA,IAAM,WAAsB;CAAE,MAAM;CAAY;CAAW;CAAS,QAAQ,QAAQ,cAAc,WAAW,YAAY,QAAQ,SAAS;AAAE"}
@@ -1,5 +1,5 @@
1
1
  import { BufferGeometry, Group, Mesh, type Material, type MeshStandardNodeMaterial, type UniformNode } from 'three/webgpu';
2
- import type { TreeDefinition } from '../definition';
2
+ import type { MaterialFeatures, TranslucencyDefinition, TreeDefinition } from '../definition';
3
3
  import { type TreeData } from '../generator';
4
4
  import { type SeasonUniform } from '../season';
5
5
  import { type TextureOptions } from '../textures';
@@ -41,12 +41,39 @@ export declare class Tree extends Group {
41
41
  /** This tree's response to the Wind, from `definition.wind`; `windResponse.set(...)` changes it live. */
42
42
  readonly windResponse: WindResponse;
43
43
  private readonly windBinding;
44
+ private readonly features;
44
45
  /**
45
46
  * Resolves once every texture of this tree has loaded (at once for a tree without textures);
46
47
  * rejects if one fails. Await it before a first render that must show the textures.
47
48
  */
48
49
  readonly ready: Promise<void>;
49
50
  constructor(definition: TreeDefinition, data: TreeData, options?: TreeOptions);
51
+ /**
52
+ * Crown Normals amount (0..1), from the Definition's `materials.leaf.crownNormals`; null when it is off.
53
+ * Setting it (clamped to 0..1) only writes a uniform: no regeneration, no recompile. Throws on a
54
+ * tree without Crown Normals (switching the feature on needs a new tree).
55
+ */
56
+ get crownNormals(): number | null;
57
+ set crownNormals(value: number);
58
+ /**
59
+ * Leaf Translucency settings (a copy), from the Definition's `materials.leaf.translucency`; null when it
60
+ * is off. Setting any of them (each clamped to 0..1, the others kept) only writes uniforms: no
61
+ * regeneration, no recompile. Throws on a tree without Leaf Translucency.
62
+ */
63
+ get translucency(): TranslucencyDefinition | null;
64
+ set translucency(value: Partial<TranslucencyDefinition>);
65
+ /**
66
+ * The Material Features this tree shows, with their current (possibly live-tuned) values: the
67
+ * Definition's (see `materialFeaturesOf`), except that Crown Normals at 0 count as off.
68
+ */
69
+ get materialFeatures(): MaterialFeatures;
70
+ /**
71
+ * Structural Occlusion strength (0..1), from the Definition's `materials.occlusion`; null when it has none.
72
+ * Setting it (clamped to 0..1) only writes a uniform: no regeneration, no recompile. Throws on a tree
73
+ * without Structural Occlusion (there is no baked occlusion to show).
74
+ */
75
+ get occlusionStrength(): number | null;
76
+ set occlusionStrength(value: number);
50
77
  /**
51
78
  * The Wind this tree sways with (shared with every other tree using it). Assigning another
52
79
  * Wind only rebinds uniforms: no regeneration, no recompile.
@@ -1 +1 @@
1
- {"version":3,"file":"Tree.d.ts","sourceRoot":"","sources":["../../src/tree/Tree.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EACd,KAAK,EAGL,IAAI,EACJ,KAAK,QAAQ,EACb,KAAK,wBAAwB,EAE7B,KAAK,WAAW,EACjB,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAqC,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,gBAAgB,IAAI,gBAAgB,CAEvC;IAED;;;;OAIG;IACH,IAAI,iBAAiB,IAAI,MAAM,GAAG,IAAI,CAErC;IAED,IAAI,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAElC;IAED;;;OAGG;IACH,IAAI,IAAI,IAAI,IAAI,CAEf;IAED,IAAI,IAAI,CAAC,KAAK,EAAE,IAAI,EAEnB;IAED;;;;OAIG;IACH,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,IAAI,MAAM,CAAC,KAAK,EAAE,MAAM,EAEvB;IAED;;;OAGG;IACH,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,IAAI,MAAM,CAAC,KAAK,EAAE,MAAM,EAEvB;IAED,sGAAsG;IAC7F,OAAO,IAAI,IAAI;CAWzB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@casmo/tree.js",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Procedural trees for three.js (WebGPURenderer, TSL node materials).",
5
5
  "keywords": [
6
6
  "three",
@@ -1 +0,0 @@
1
- {"version":3,"file":"apply-CcodnAbs.js","names":[],"sources":["../src/styles/realistic/textures.ts","../src/styles/apply.ts"],"sourcesContent":["import type { BarkType, LeafType } from '../../definition/types';\n\n/**\n * The realistic Style's texture files, as relative URLs (resolved against the texture base path).\n * All made by scripts/generate-textures.mjs. `bark`/`barkNormal` are the furrowed pair, `leaf` the\n * broad card and `needles` the needle card (the generic broadleaf / conifer use these).\n */\nexport const TEXTURES = {\n bark: 'realistic/bark.png',\n barkNormal: 'realistic/bark-normal.png',\n leaf: 'realistic/leaf.png',\n needles: 'realistic/needles.png',\n} as const;\n\n/** The alpha-cut leaf card texture for each Leaf Type. */\nexport const LEAF_TEXTURES: Readonly<Record<LeafType, string>> = {\n broad: TEXTURES.leaf,\n lobed: 'realistic/leaf-lobed.png',\n palmate: 'realistic/leaf-palmate.png',\n compound: 'realistic/leaf-compound.png',\n needle: TEXTURES.needles,\n scale: 'realistic/scale.png',\n};\n\n/** The colour + normal map pair for each Bark Type. */\nexport const BARK_TEXTURES: Readonly<Record<BarkType, { map: string; normalMap: string }>> = {\n furrowed: { map: TEXTURES.bark, normalMap: TEXTURES.barkNormal },\n smooth: { map: 'realistic/bark-smooth.png', normalMap: 'realistic/bark-smooth-normal.png' },\n papery: { map: 'realistic/bark-papery.png', normalMap: 'realistic/bark-papery-normal.png' },\n fibrous: { map: 'realistic/bark-fibrous.png', normalMap: 'realistic/bark-fibrous-normal.png' },\n plated: { map: 'realistic/bark-plated.png', normalMap: 'realistic/bark-plated-normal.png' },\n};\n","// Style.apply (ADR 0005): a Style turns a Style-neutral Species (or an existing Tree Definition)\n// into a complete Tree Definition by choosing only the look: shading, polygon detail, how the\n// Leaf Type and Bark Type are drawn, and textures. Shape fields pass through untouched.\nimport { extendDefinition, parseDefinition, type DefinitionPatch } from '../definition/parse';\nimport {\n CURRENT_SCHEMA_VERSION,\n type BarkMaterialDefinition,\n type BarkType,\n type LeafMaterialDefinition,\n type LeafShape,\n type LeafType,\n type TreeDefinition,\n type TreeDefinitionInput,\n} from '../definition/types';\nimport type { SpeciesBarkDefinition, SpeciesDefinition, SpeciesFoliageDefinition } from '../species/types';\nimport { styleOfShading, styleShading, type StyleName } from './names';\nimport { BARK_TEXTURES, LEAF_TEXTURES } from './realistic/textures';\n\n/** Polygon detail of one tree part. */\ninterface Detail {\n sides: number;\n sections: number;\n}\n\n/** How a Style draws one Leaf Type. */\ninterface LeafLook {\n shape: LeafShape;\n /** Leaves per terminal branch at density 1 (count = round(density × this)). */\n perDensity: number;\n /** Leaf size = the Species' real leaf-spray size × this. */\n sizeScale: number;\n material: LeafMaterialDefinition;\n}\n\n/** Everything a Style decides about a tree: its look (its shading is in names.ts). */\ninterface StyleLook {\n trunk: Detail;\n /** Detail per branch level; deeper levels reuse the last entry. */\n branches: Detail[];\n bark(type: BarkType): Omit<BarkMaterialDefinition, 'type' | 'color'>;\n leaf(type: LeafType): LeafLook;\n /** Faces around each Fruit (`fruit.sides`): few flat facets in low-poly, smooth in the others. */\n fruitSides: number;\n}\n\nconst isNeedleLike = (type: LeafType) => type === 'needle' || type === 'scale';\nconst untexturedLeaf: LeafMaterialDefinition = { roughness: 1, map: null, alphaTest: 0.5 };\nconst untexturedBark = () => ({ roughness: 1, map: null, normalMap: null });\n\n// Low-poly and stylized are calibrated so a Species with density 0.5 and leaf-spray size 0.35 m comes\n// out close to each Style's own broadleaf / conifer Definitions. Realistic draws far more (cheap, 2\n// triangle) cards per twig than its own Definitions: a Species has fewer twigs than the realistic\n// generic trees (the low-poly and stylized triangle budgets cap them at about 40-90), so the cards\n// have to fill the crown. Deeper branch levels get little detail (twigs are thin and many).\nconst LOOKS = {\n 'low-poly': {\n trunk: { sides: 5, sections: 4 },\n branches: [{ sides: 4, sections: 2 }, { sides: 3, sections: 1 }],\n bark: untexturedBark,\n fruitSides: 4,\n leaf: (type) =>\n isNeedleLike(type)\n ? { shape: 'needle', perDensity: 14, sizeScale: 1.86, material: untexturedLeaf }\n : { shape: 'clump', perDensity: 4, sizeScale: 2.86, material: untexturedLeaf },\n },\n stylized: {\n trunk: { sides: 10, sections: 8 },\n branches: [{ sides: 6, sections: 3 }, { sides: 4, sections: 1 }, { sides: 3, sections: 1 }],\n bark: untexturedBark,\n fruitSides: 6,\n // All puffs; smaller and denser for needle / scale foliage.\n leaf: (type) =>\n isNeedleLike(type)\n ? { shape: 'puff', perDensity: 8, sizeScale: 1.7, material: untexturedLeaf }\n : { shape: 'puff', perDensity: 4, sizeScale: 3.14, material: untexturedLeaf },\n },\n realistic: {\n trunk: { sides: 12, sections: 10 },\n branches: [{ sides: 8, sections: 6 }, { sides: 5, sections: 4 }, { sides: 3, sections: 2 }],\n // A texture per Bark Type and per Leaf Type (scripts/generate-textures.mjs).\n bark: (type) => ({ roughness: 0.95, ...BARK_TEXTURES[type] }),\n fruitSides: 9,\n leaf: (type) =>\n isNeedleLike(type)\n ? { shape: 'card', perDensity: 120, sizeScale: 1.7, material: { roughness: 0.7, map: LEAF_TEXTURES[type], alphaTest: 0.4 } }\n : { shape: 'card', perDensity: 80, sizeScale: 2.2, material: { roughness: 0.65, map: LEAF_TEXTURES[type], alphaTest: 0.4 } },\n },\n} satisfies Record<StyleName, StyleLook>;\n\n/** What `Style.apply` accepts: a Species, or a Tree Definition to re-style. */\nexport type StyleSource = SpeciesDefinition | TreeDefinition | TreeDefinitionInput;\n\n/** The Style-neutral content of a source: every non-look field, plus foliage and bark. */\ninterface Neutral {\n /** Definition fields that pass through (shape, Season, Wind, Sculpts, Fruit, ...). */\n base: Record<string, unknown> & { trunk: object; branches: object[] };\n foliage: SpeciesFoliageDefinition;\n bark: SpeciesBarkDefinition;\n}\n\nfunction fromSpecies(species: SpeciesDefinition): Neutral {\n const { id, name, trunk, branches, season, wind, variation, fruit, foliage, bark } = species;\n return {\n base: {\n schemaVersion: CURRENT_SCHEMA_VERSION,\n name,\n species: id,\n trunk,\n branches,\n season,\n wind,\n variation,\n sculpts: [],\n ...(fruit ? { fruit } : {}),\n },\n foliage,\n bark,\n };\n}\n\nfunction fromDefinition(input: TreeDefinition | TreeDefinitionInput): Neutral {\n const definition = parseDefinition(input);\n const { leaves, materials, ...base } = definition;\n // Definitions not made by `apply` carry no Leaf / Bark Type: guess them from how they are drawn.\n const leafType = leaves.type ?? (leaves.shape === 'needle' || /needle/.test(materials.leaf.map ?? '') ? 'needle' : 'broad');\n const source = LOOKS[styleOfShading(materials.shading)].leaf(leafType);\n return {\n base,\n foliage: {\n type: leafType,\n density: leaves.count / source.perDensity,\n size: leaves.size / source.sizeScale,\n sizeVariation: leaves.sizeVariation,\n start: leaves.start,\n angle: leaves.angle,\n },\n bark: { type: materials.bark.type ?? 'furrowed', color: materials.bark.color },\n };\n}\n\nfunction draw(name: StyleName, { base, foliage, bark }: Neutral): TreeDefinition {\n const look: StyleLook = LOOKS[name];\n const leaf = look.leaf(foliage.type);\n const fruit = base.fruit as TreeDefinition['fruit'];\n return parseDefinition({\n ...base,\n ...(fruit ? { fruit: { ...fruit, sides: look.fruitSides } } : {}),\n trunk: { ...base.trunk, ...look.trunk },\n branches: base.branches.map((level, i) => ({ ...level, ...look.branches[Math.min(i, look.branches.length - 1)] })),\n leaves: {\n type: foliage.type,\n count: Math.round(foliage.density * leaf.perDensity),\n shape: leaf.shape,\n size: foliage.size * leaf.sizeScale,\n sizeVariation: foliage.sizeVariation,\n start: foliage.start,\n angle: foliage.angle,\n },\n materials: {\n shading: styleShading(name),\n bark: { type: bark.type, color: bark.color, ...look.bark(bark.type) },\n leaf: { ...leaf.material },\n },\n });\n}\n\n/**\n * Applies a built-in Style's look to a Species or a Tree Definition (see `TreeStyle.apply`).\n * Pure: never mutates its inputs.\n */\nexport function applyStyle(name: StyleName, source: StyleSource, overrides?: DefinitionPatch): TreeDefinition {\n const neutral = 'schemaVersion' in source ? fromDefinition(source) : fromSpecies(source);\n const definition = draw(name, neutral);\n return overrides ? extendDefinition(definition, overrides) : definition;\n}\n"],"mappings":";;;;;;;AAOA,IAAa,WAAW;CACtB,MAAM;CACN,YAAY;CACZ,MAAM;CACN,SAAS;AACX;;AAGA,IAAa,gBAAoD;CAC/D,OAAO,SAAS;CAChB,OAAO;CACP,SAAS;CACT,UAAU;CACV,QAAQ,SAAS;CACjB,OAAO;AACT;;AAGA,IAAa,gBAAgF;CAC3F,UAAU;EAAE,KAAK,SAAS;EAAM,WAAW,SAAS;CAAW;CAC/D,QAAQ;EAAE,KAAK;EAA6B,WAAW;CAAmC;CAC1F,QAAQ;EAAE,KAAK;EAA6B,WAAW;CAAmC;CAC1F,SAAS;EAAE,KAAK;EAA8B,WAAW;CAAoC;CAC7F,QAAQ;EAAE,KAAK;EAA6B,WAAW;CAAmC;AAC5F;;ACcA,IAAM,gBAAgB,SAAmB,SAAS,YAAY,SAAS;AACvE,IAAM,iBAAyC;CAAE,WAAW;CAAG,KAAK;CAAM,WAAW;AAAI;AACzF,IAAM,wBAAwB;CAAE,WAAW;CAAG,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