@casmo/tree.js 0.1.1 → 0.2.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 (190) hide show
  1. package/README.md +106 -16
  2. package/dist/apply-CcodnAbs.js +250 -0
  3. package/dist/apply-CcodnAbs.js.map +1 -0
  4. package/dist/bake/index.d.ts +2 -2
  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 +7 -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 +95 -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 +10 -1
  22. package/dist/forest/Forest.d.ts.map +1 -1
  23. package/dist/forest/nodes.d.ts +4 -1
  24. package/dist/forest/nodes.d.ts.map +1 -1
  25. package/dist/{forest-OX9WvAwh.js → forest-DTrD8puH.js} +695 -546
  26. package/dist/forest-DTrD8puH.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/fruit.d.ts +28 -0
  30. package/dist/generator/fruit.d.ts.map +1 -0
  31. package/dist/generator/growth.d.ts +1 -1
  32. package/dist/generator/growth.d.ts.map +1 -1
  33. package/dist/generator/index.d.ts +4 -4
  34. package/dist/generator/index.d.ts.map +1 -1
  35. package/dist/generator/leaf-shapes.d.ts +33 -1
  36. package/dist/generator/leaf-shapes.d.ts.map +1 -1
  37. package/dist/generator/trunk.d.ts +8 -2
  38. package/dist/generator/trunk.d.ts.map +1 -1
  39. package/dist/generator/types.d.ts +34 -5
  40. package/dist/generator/types.d.ts.map +1 -1
  41. package/dist/index.d.ts +4 -2
  42. package/dist/index.d.ts.map +1 -1
  43. package/dist/index.js +48 -4
  44. package/dist/index.js.map +1 -1
  45. package/dist/materials/index.d.ts +6 -0
  46. package/dist/materials/index.d.ts.map +1 -1
  47. package/dist/names-C6-wuJ29.js +589 -0
  48. package/dist/names-C6-wuJ29.js.map +1 -0
  49. package/dist/react/Tree.d.ts +5 -2
  50. package/dist/react/Tree.d.ts.map +1 -1
  51. package/dist/react.js +10 -6
  52. package/dist/react.js.map +1 -1
  53. package/dist/season/nodes.d.ts +16 -0
  54. package/dist/season/nodes.d.ts.map +1 -1
  55. package/dist/season/profile.d.ts +26 -0
  56. package/dist/season/profile.d.ts.map +1 -1
  57. package/dist/species/almond.js +213 -0
  58. package/dist/species/almond.js.map +1 -0
  59. package/dist/species/almond.json +201 -0
  60. package/dist/species/apple.js +220 -0
  61. package/dist/species/apple.js.map +1 -0
  62. package/dist/species/apple.json +211 -0
  63. package/dist/species/ash.js +177 -0
  64. package/dist/species/ash.js.map +1 -0
  65. package/dist/species/ash.json +168 -0
  66. package/dist/species/beech.js +164 -0
  67. package/dist/species/beech.js.map +1 -0
  68. package/dist/species/beech.json +158 -0
  69. package/dist/species/birch.js +160 -0
  70. package/dist/species/birch.js.map +1 -0
  71. package/dist/species/birch.json +154 -0
  72. package/dist/species/catalog.d.ts +61 -0
  73. package/dist/species/catalog.d.ts.map +1 -0
  74. package/dist/species/cedar.js +159 -0
  75. package/dist/species/cedar.js.map +1 -0
  76. package/dist/species/cedar.json +159 -0
  77. package/dist/species/cherry.js +227 -0
  78. package/dist/species/cherry.js.map +1 -0
  79. package/dist/species/cherry.json +215 -0
  80. package/dist/species/chestnut.js +220 -0
  81. package/dist/species/chestnut.js.map +1 -0
  82. package/dist/species/chestnut.json +211 -0
  83. package/dist/species/douglas-fir.js +164 -0
  84. package/dist/species/douglas-fir.js.map +1 -0
  85. package/dist/species/douglas-fir.json +161 -0
  86. package/dist/species/elm.js +163 -0
  87. package/dist/species/elm.js.map +1 -0
  88. package/dist/species/elm.json +154 -0
  89. package/dist/species/hemlock.js +165 -0
  90. package/dist/species/hemlock.js.map +1 -0
  91. package/dist/species/hemlock.json +162 -0
  92. package/dist/species/hickory.js +190 -0
  93. package/dist/species/hickory.js.map +1 -0
  94. package/dist/species/hickory.json +183 -0
  95. package/dist/species/index.d.ts +10 -0
  96. package/dist/species/index.d.ts.map +1 -0
  97. package/dist/species/juniper.js +148 -0
  98. package/dist/species/juniper.js.map +1 -0
  99. package/dist/species/juniper.json +145 -0
  100. package/dist/species/loaders.d.ts +7 -0
  101. package/dist/species/loaders.d.ts.map +1 -0
  102. package/dist/species/mahogany.js +191 -0
  103. package/dist/species/mahogany.js.map +1 -0
  104. package/dist/species/mahogany.json +187 -0
  105. package/dist/species/maple.js +167 -0
  106. package/dist/species/maple.js.map +1 -0
  107. package/dist/species/maple.json +162 -0
  108. package/dist/species/oak.js +210 -0
  109. package/dist/species/oak.js.map +1 -0
  110. package/dist/species/oak.json +203 -0
  111. package/dist/species/olive.js +179 -0
  112. package/dist/species/olive.js.map +1 -0
  113. package/dist/species/olive.json +172 -0
  114. package/dist/species/peach.js +213 -0
  115. package/dist/species/peach.js.map +1 -0
  116. package/dist/species/peach.json +201 -0
  117. package/dist/species/pear.js +203 -0
  118. package/dist/species/pear.js.map +1 -0
  119. package/dist/species/pear.json +191 -0
  120. package/dist/species/pine.js +153 -0
  121. package/dist/species/pine.js.map +1 -0
  122. package/dist/species/pine.json +153 -0
  123. package/dist/species/plum.js +227 -0
  124. package/dist/species/plum.js.map +1 -0
  125. package/dist/species/plum.json +215 -0
  126. package/dist/species/red-oak.js +210 -0
  127. package/dist/species/red-oak.js.map +1 -0
  128. package/dist/species/red-oak.json +203 -0
  129. package/dist/species/redwood.js +164 -0
  130. package/dist/species/redwood.js.map +1 -0
  131. package/dist/species/redwood.json +161 -0
  132. package/dist/species/sequoia.js +157 -0
  133. package/dist/species/sequoia.js.map +1 -0
  134. package/dist/species/sequoia.json +157 -0
  135. package/dist/species/spruce.js +160 -0
  136. package/dist/species/spruce.js.map +1 -0
  137. package/dist/species/spruce.json +157 -0
  138. package/dist/species/teak.js +156 -0
  139. package/dist/species/teak.js.map +1 -0
  140. package/dist/species/teak.json +148 -0
  141. package/dist/species/types.d.ts +61 -0
  142. package/dist/species/types.d.ts.map +1 -0
  143. package/dist/species/walnut.js +210 -0
  144. package/dist/species/walnut.js.map +1 -0
  145. package/dist/species/walnut.json +203 -0
  146. package/dist/species/white-oak.js +203 -0
  147. package/dist/species/white-oak.js.map +1 -0
  148. package/dist/species/white-oak.json +199 -0
  149. package/dist/species.js +160 -0
  150. package/dist/species.js.map +1 -0
  151. package/dist/styles/apply.d.ts +12 -0
  152. package/dist/styles/apply.d.ts.map +1 -0
  153. package/dist/styles/low-poly/index.d.ts +1 -1
  154. package/dist/styles/low-poly/index.d.ts.map +1 -1
  155. package/dist/styles/low-poly.js +9 -8
  156. package/dist/styles/low-poly.js.map +1 -1
  157. package/dist/styles/names.d.ts +28 -0
  158. package/dist/styles/names.d.ts.map +1 -0
  159. package/dist/styles/realistic/index.d.ts +3 -8
  160. package/dist/styles/realistic/index.d.ts.map +1 -1
  161. package/dist/styles/realistic/textures.d.ts +20 -0
  162. package/dist/styles/realistic/textures.d.ts.map +1 -0
  163. package/dist/styles/realistic.js +10 -16
  164. package/dist/styles/realistic.js.map +1 -1
  165. package/dist/styles/registry.d.ts +2 -13
  166. package/dist/styles/registry.d.ts.map +1 -1
  167. package/dist/styles/stylized/index.d.ts +1 -1
  168. package/dist/styles/stylized/index.d.ts.map +1 -1
  169. package/dist/styles/stylized.js +9 -8
  170. package/dist/styles/stylized.js.map +1 -1
  171. package/dist/styles/types.d.ts +16 -2
  172. package/dist/styles/types.d.ts.map +1 -1
  173. package/dist/textures/realistic/bark-fibrous-normal.png +0 -0
  174. package/dist/textures/realistic/bark-fibrous.png +0 -0
  175. package/dist/textures/realistic/bark-papery-normal.png +0 -0
  176. package/dist/textures/realistic/bark-papery.png +0 -0
  177. package/dist/textures/realistic/bark-plated-normal.png +0 -0
  178. package/dist/textures/realistic/bark-plated.png +0 -0
  179. package/dist/textures/realistic/bark-smooth-normal.png +0 -0
  180. package/dist/textures/realistic/bark-smooth.png +0 -0
  181. package/dist/textures/realistic/leaf-compound.png +0 -0
  182. package/dist/textures/realistic/leaf-lobed.png +0 -0
  183. package/dist/textures/realistic/leaf-palmate.png +0 -0
  184. package/dist/textures/realistic/scale.png +0 -0
  185. package/dist/tree/Tree.d.ts +6 -4
  186. package/dist/tree/Tree.d.ts.map +1 -1
  187. package/package.json +9 -2
  188. package/dist/forest-OX9WvAwh.js.map +0 -1
  189. package/dist/types-BZjHhNz7.js +0 -20
  190. package/dist/types-BZjHhNz7.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import type { TreeDefinition } from '../definition';
2
2
  import type { GeometryBuffers, TreeData, TreeSkeleton } from './types';
3
3
  export { growthTiming } from './growth';
4
- export type { GrowthTiming, GrowthWindow, GeometryBuffers, TreeAttributes, VertexAttribute, SkeletonBranch, SkeletonLeaf, SkeletonPoint, TreeData, TreeSkeleton, Vec3 } from './types';
4
+ export type { GrowthTiming, GrowthWindow, GeometryBuffers, TreeAttributes, VertexAttribute, SkeletonBranch, SkeletonFruit, SkeletonLeaf, SkeletonPoint, TreeData, TreeSkeleton, Vec3 } from './types';
5
5
  /**
6
6
  * The Generator: a pure function from a (parsed) Tree Definition and a Seed to tree data.
7
7
  * No three.js, no GPU, no globals; runs in Node. Same input, same output, on every machine.
@@ -11,12 +11,12 @@ export type { GrowthTiming, GrowthWindow, GeometryBuffers, TreeAttributes, Verte
11
11
  */
12
12
  export declare function generateTree(definition: TreeDefinition, seed: number): TreeData;
13
13
  /**
14
- * Height of the (possibly Sculpted) trunk's tip: the scale of a tree's Wind sway. A Sculpt may
15
- * delete the trunk (an empty tree, nothing sways); the height is then 1.
14
+ * Height of the tallest (possibly Sculpted) Stem: the scale of a tree's Wind sway. For an upright
15
+ * trunk that is its tip. A Sculpt may delete every Stem (an empty tree, nothing sways); it is then 1.
16
16
  */
17
17
  export declare function trunkHeight(skeleton: Pick<TreeSkeleton, 'branches'>): number;
18
18
  /** Stable 32-bit hash (hex) of the generated geometry buffers, for determinism checks. */
19
19
  export declare function hashGeometry(geometry: GeometryBuffers): string;
20
- /** Stable hash of a tree's generated geometry (wood and leaves). */
20
+ /** Stable hash of a tree's generated geometry (wood, leaves and, if any, Fruit). */
21
21
  export declare function hashTreeData(data: TreeData): string;
22
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/generator/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAWpD,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvE,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEvL;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,CA6B/E;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,GAAG,MAAM,CAG5E;AAED,0FAA0F;AAC1F,wBAAgB,YAAY,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM,CAE9D;AAED,oEAAoE;AACpE,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAEnD"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/generator/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAYpD,OAAO,KAAK,EAAE,eAAe,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAEvE,OAAO,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACxC,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEtM;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,UAAU,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,GAAG,QAAQ,CA4C/E;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,IAAI,CAAC,YAAY,EAAE,UAAU,CAAC,GAAG,MAAM,CAI5E;AAED,0FAA0F;AAC1F,wBAAgB,YAAY,CAAC,QAAQ,EAAE,eAAe,GAAG,MAAM,CAE9D;AAED,oFAAoF;AACpF,wBAAgB,YAAY,CAAC,IAAI,EAAE,QAAQ,GAAG,MAAM,CAInD"}
@@ -1,10 +1,42 @@
1
1
  import type { LeafShape, VariationDefinition } from '../definition';
2
- import type { GeometryBuffers, GrowthWindow, SkeletonLeaf } from './types';
2
+ import { type PartInfo } from './attributes';
3
+ import type { GeometryBuffers, GrowthWindow, SkeletonLeaf, Vec3 } from './types';
3
4
  import { type PartSway } from './wind';
5
+ /**
6
+ * A closed solid leaf shape in a leaf's local frame, in units of the leaf size:
7
+ * x = across (side), y = the leaf normal, z = along the leaf direction (0 = attachment, 1 = tip).
8
+ * `normals` are outward unit normals (smooth; a flat-shaded material makes them faceted).
9
+ */
10
+ export interface SolidTemplate {
11
+ positions: Vec3[];
12
+ normals: Vec3[];
13
+ triangles: [number, number, number][];
14
+ }
15
+ /** Low-poly foliage ball: an icosahedron of diameter 1, from the attachment point out along the leaf. */
16
+ export declare function clumpTemplate(): SolidTemplate;
17
+ /** Fixes each triangle's winding so its front face points along its vertex normals (CCW = front). */
18
+ export declare function orient(template: SolidTemplate): SolidTemplate;
4
19
  /**
5
20
  * Leaf geometry for the solid shapes ('clump', 'needle', 'puff'): one small closed mesh per leaf,
6
21
  * placed in the leaf's frame (across, normal, direction) and scaled by its size. Like cards,
7
22
  * every vertex carries the leaf's tint as its colour and the leaf's part attributes.
8
23
  */
9
24
  export declare function solidLeafGeometry(leaves: SkeletonLeaf[], shape: Exclude<LeafShape, 'card'>, level: number, seed: number, variation?: Pick<VariationDefinition, 'season'>, growth?: GrowthWindow[], branchSway?: ReadonlyMap<string, PartSway>): GeometryBuffers;
25
+ /** One placed copy of a solid template: its base point, frame (direction, normal), size and tint. */
26
+ export interface SolidPlacement {
27
+ position: Vec3;
28
+ /** Unit vector from the base point to the far end (template z). */
29
+ direction: Vec3;
30
+ /** Unit vector across it (template y), perpendicular to `direction`. */
31
+ normal: Vec3;
32
+ size: number;
33
+ /** Vertex colour (RGB multiplier). */
34
+ tint: Vec3;
35
+ }
36
+ /**
37
+ * One small closed mesh per placement: the template in the placement's frame
38
+ * (across, normal, direction), scaled by its size, every vertex carrying the placement's tint
39
+ * as its colour and its part attributes (`part`).
40
+ */
41
+ export declare function solidGeometry<P extends SolidPlacement>(template: SolidTemplate, placements: readonly P[], part: (placement: P, index: number) => PartInfo): GeometryBuffers;
10
42
  //# sourceMappingURL=leaf-shapes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"leaf-shapes.d.ts","sourceRoot":"","sources":["../../src/generator/leaf-shapes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAIpE,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY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AAM,CAAC,EACjC,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,SAAS,GAAE,IAAI,CAAC,mBAAmB,EAAE,QAAQ,CAAiB,EAC9D,MAAM,GAAE,YAAY,EAAO,EAC3B,UAAU,GAAE,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAa,GACpD,eAAe,CAUjB;AAED,qGAAqG;AACrG,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,IAAI,CAAC;IACf,mEAAmE;IACnE,SAAS,EAAE,IAAI,CAAC;IAChB,wEAAwE;IACxE,MAAM,EAAE,IAAI,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,sCAAsC;IACtC,IAAI,EAAE,IAAI,CAAC;CACZ;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,cAAc,EACpD,QAAQ,EAAE,aAAa,EACvB,UAAU,EAAE,SAAS,CAAC,EAAE,EACxB,IAAI,EAAE,CAAC,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,MAAM,KAAK,QAAQ,GAC9C,eAAe,CA4BjB"}
@@ -1,6 +1,12 @@
1
1
  import type { TreeDefinition } from '../definition';
2
2
  import type { Random } from '../random';
3
3
  import type { SkeletonBranch } from './types';
4
- /** Builds the trunk centre line from the Definition, varied by the Seed within its ranges. */
5
- export declare function buildTrunk(definition: TreeDefinition, random: Random): SkeletonBranch;
4
+ /**
5
+ * Builds the Stems: `trunk.stems` full trunks standing in a small ring at the base, paths "0", "1", ...
6
+ *
7
+ * Path stability (ADR 0003): Stem 0's centre line draws from `random.fork('trunk')` exactly as a
8
+ * single trunk always did, Stem i > 0 from `random.fork('trunk/<i>')`; the ring and the leans come
9
+ * from `random.fork('stems')`. So a single upright Stem without gravity is today's trunk, bit for bit.
10
+ */
11
+ export declare function buildStems(definition: TreeDefinition, random: Random): SkeletonBranch[];
6
12
  //# sourceMappingURL=trunk.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"trunk.d.ts","sourceRoot":"","sources":["../../src/generator/trunk.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,KAAK,EAAE,cAAc,EAAiB,MAAM,SAAS,CAAC;AAE7D,8FAA8F;AAC9F,wBAAgB,UAAU,CAAC,UAAU,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,cAAc,CAkBrF"}
1
+ {"version":3,"file":"trunk.d.ts","sourceRoot":"","sources":["../../src/generator/trunk.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAmB,MAAM,eAAe,CAAC;AACrE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACxC,OAAO,KAAK,EAAE,cAAc,EAAuB,MAAM,SAAS,CAAC;AAenE;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,UAAU,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,GAAG,cAAc,EAAE,CAevF"}
@@ -6,7 +6,7 @@ export interface SkeletonPoint {
6
6
  }
7
7
  /**
8
8
  * One branch of the skeleton. `path` is stable for a given Definition and Seed
9
- * (ADR 0003): the trunk is "0", its children "0.0", "0.1", ... (ticket #4).
9
+ * (ADR 0003): the trunk is "0", its children "0.0", "0.1", ... (ticket #4). Extra Stems are "1", "2", ...
10
10
  */
11
11
  export interface SkeletonBranch {
12
12
  path: string;
@@ -47,10 +47,34 @@ export interface SkeletonLeaf {
47
47
  */
48
48
  tint: Vec3;
49
49
  }
50
+ /**
51
+ * One Fruit (ADR 0006). `id` is `<branch path>/<index>`, stable for a given Definition and Seed.
52
+ */
53
+ export interface SkeletonFruit {
54
+ id: string;
55
+ /** Path of the (outermost) branch the Fruit grows on. */
56
+ branch: string;
57
+ /** Index of the Fruit on its branch (0 nearest the branch base). */
58
+ index: number;
59
+ /** Where the Fruit sits on its branch, as a fraction (0..1) of the branch length. */
60
+ attach: number;
61
+ /** Attachment point on the branch centre line (the top of the Fruit). */
62
+ position: Vec3;
63
+ /** Unit vector from the attachment point through the Fruit (down for hanging Fruit). */
64
+ direction: Vec3;
65
+ /** A unit vector perpendicular to `direction` (orients the Fruit's shape). */
66
+ normal: Vec3;
67
+ /** Fruit length (attachment to far end). */
68
+ size: number;
69
+ /** The Seed's colour variation for this Fruit (RGB multiplier, as for leaves); also its vertex colour. */
70
+ tint: Vec3;
71
+ }
50
72
  export interface TreeSkeleton {
51
- /** Trunk first, then breadth first: all of level 1, all of level 2, ... */
73
+ /** Stems (trunks) first, then breadth first: all of level 1, all of level 2, ... */
52
74
  branches: SkeletonBranch[];
53
75
  leaves: SkeletonLeaf[];
76
+ /** Fruit on the outermost twigs (empty without a `fruit` block). */
77
+ fruit: SkeletonFruit[];
54
78
  }
55
79
  /** A custom per-vertex attribute: `itemSize` floats per vertex. */
56
80
  export interface VertexAttribute {
@@ -64,7 +88,7 @@ export interface VertexAttribute {
64
88
  */
65
89
  export interface TreeAttributes {
66
90
  [name: string]: VertexAttribute;
67
- /** Part level: 0 = trunk, n = branching level n, leaves = number of branch levels + 1. */
91
+ /** Part level: 0 = trunk, n = branching level n, leaves = number of branch levels + 1, Fruit = levels + 2. */
68
92
  aLevel: VertexAttribute;
69
93
  /** Position of the vertex along its part, 0 at the base to 1 at the tip. */
70
94
  aAlong: VertexAttribute;
@@ -83,12 +107,13 @@ export interface TreeAttributes {
83
107
  /**
84
108
  * Season (vec3): x = timing shift from the Seed (within ± `variation.season`), y = coverage rank,
85
109
  * z = blossom rank (0..1, leaves only; 0 on wood). See `leafSeason` in src/season.
110
+ * On Fruit: y = the Fruit's rank, z = 0 (see `fruitSeason`).
86
111
  */
87
112
  aSeason: VertexAttribute;
88
113
  /**
89
114
  * Wind weights (vec3, each 0..1): x = trunk sway (pinned at the ground, 1 at the trunk top),
90
115
  * y = branch sway (0 on the trunk, rising towards the outermost twigs), z = leaf flutter (0 on wood,
91
- * 0 at a leaf base, 1 at its tip). See `generator/wind.ts`.
116
+ * 0 at a leaf base, 1 at its tip). Fruit has its twig's branch sway at the attachment point and no flutter. See `generator/wind.ts`.
92
117
  */
93
118
  aWind: VertexAttribute;
94
119
  }
@@ -107,10 +132,12 @@ export interface GrowthWindow {
107
132
  start: number;
108
133
  end: number;
109
134
  }
110
- /** Growth windows per part, parallel to `TreeSkeleton.branches` and `TreeSkeleton.leaves`. */
135
+ /** Growth windows per part, parallel to `TreeSkeleton.branches`, `.leaves` and `.fruit`. */
111
136
  export interface GrowthTiming {
112
137
  branches: GrowthWindow[];
113
138
  leaves: GrowthWindow[];
139
+ /** Fruit grows only at the end of Growth (from about 0.9), on a fully grown twig. */
140
+ fruit: GrowthWindow[];
114
141
  }
115
142
  /** Everything the Generator produces for one Definition + Seed. Pure data, Node-safe. */
116
143
  export interface TreeData {
@@ -120,6 +147,8 @@ export interface TreeData {
120
147
  wood: GeometryBuffers;
121
148
  /** Leaf cards, vertex coloured. Empty buffers for a bare tree. */
122
149
  leaves: GeometryBuffers;
150
+ /** Fruit solids, vertex coloured (the Seed's tint). Empty buffers without Fruit. */
151
+ fruit: GeometryBuffers;
123
152
  /** When each part grows (the Seed shifts it within `variation.growth`). Also in the `aGrowth` attribute. */
124
153
  growth: GrowthTiming;
125
154
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/generator/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAE5C,2CAA2C;AAC3C,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,IAAI,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,wDAAwD;IACxD,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,gDAAgD;IAChD,KAAK,EAA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
1
1
  export { createTree, Tree, type CreateTreeOptions, type TreeOptions } from './tree';
2
2
  export * from './definition';
3
3
  export * from './season';
4
- export { hashGeometry, hashTreeData, type TreeData, type GrowthTiming, type GrowthWindow, type TreeSkeleton, type SkeletonBranch, type SkeletonPoint, type SkeletonLeaf, type GeometryBuffers, type TreeAttributes, type VertexAttribute, type Vec3, } from './generator';
4
+ export { hashGeometry, hashTreeData, type TreeData, type GrowthTiming, type GrowthWindow, type TreeSkeleton, type SkeletonBranch, type SkeletonPoint, type SkeletonLeaf, type SkeletonFruit, type GeometryBuffers, type TreeAttributes, type VertexAttribute, type Vec3, } from './generator';
5
5
  export { createRandom, type Random } from './random';
6
6
  export { createBarkMaterial, createLeafMaterial } from './materials';
7
7
  export { DEFAULT_TEXTURE_BASE_PATH, getTextureOptions, loadTexture, resolveTextureUrl, setTextureOptions, textureReady, type TextureKind, type TextureOptions, } from './textures';
8
8
  export { assertWebGPURenderer, UnsupportedRendererError } from './renderer';
9
9
  export { Wind, sceneWind, WindResponse, type WindDirection, type WindOptions } from './wind';
10
10
  export type { TreeStyle } from './styles/types';
11
- export { loadStyle, STYLE_NAMES, type StyleName } from './styles/registry';
11
+ export type { StyleSource } from './styles/apply';
12
+ export type { SpeciesDefinition, SpeciesTrunkDefinition, SpeciesBranchLevelDefinition, SpeciesFoliageDefinition, SpeciesBarkDefinition, SpeciesFruitDefinition, } from './species/types';
13
+ export { loadStyle, STYLE_NAMES, styleLabel, styleOfShading, type StyleName } from './styles/registry';
12
14
  export { bakeTree, disposeBakedTree, exportBakedTree, type BakeOptions, type ExportBakedTreeOptions, } from './bake';
13
15
  export { createForest, Forest, ForestTree, ForestVariant, type ForestOptions, type ForestPlacement, type ForestInstanceState, type ForestTreeTraits, } from './forest';
14
16
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,IAAI,E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,EAAE,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACvG,OAAO,EACL,QAAQ,EACR,gBAAgB,EAChB,eAAe,EACf,KAAK,WAAW,EAChB,KAAK,sBAAsB,GAC5B,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,YAAY,EACZ,MAAM,EACN,UAAU,EACV,aAAa,EACb,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,GACtB,MAAM,UAAU,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { n as MAX_BRANCH_LEVELS, t as CURRENT_SCHEMA_VERSION } from "./types-BZjHhNz7.js";
2
- import { A as hashTreeData, B as srgbToLinear, C as loadTexture, D as clampGrowth, E as textureReady, F as leafSeasonAttribute, G as fetchDefinition, H as wrapSeason, I as partSeasonAt, J as DEFAULT_BRANCH_LEVEL, K as parseDefinition, L as sampleTrack, M as evaluateSeason, N as hexToLinear, O as growPositions, P as leafSeason, R as seasonShift, S as getTextureOptions, T as setTextureOptions, U as createRandom, V as woodSeasonAttribute, W as extendDefinition, Y as DEFAULT_DEFINITION, _ as createBarkMaterial, b as BARK_REPEAT, c as createTree, d as Wind, f as sceneWind, g as assertWebGPURenderer, h as UnsupportedRendererError, i as ForestVariant, j as KEYFRAME_EPSILON, k as hashGeometry, l as Tree, m as createSeasonNodes, n as Forest, o as STYLE_NAMES, p as applySeasonToLeafMaterial, q as TreeDefinitionError, r as ForestTree, s as loadStyle, t as createForest, u as WindResponse, v as createLeafMaterial, w as resolveTextureUrl, x as DEFAULT_TEXTURE_BASE_PATH, y as isFlatShading, z as segmentWeight } from "./forest-OX9WvAwh.js";
1
+ import { _ as FRUIT_TYPES, a as extendDefinition, c as TreeDefinitionError, d as DEFAULT_FRUIT, f as DEFAULT_FRUIT_AMOUNT, g as CURRENT_SCHEMA_VERSION, h as BARK_TYPES, l as DEFAULT_BRANCH_LEVEL, m as coneCurve, n as styleLabel, o as fetchDefinition, p as DEFAULT_FRUIT_COLOR, r as styleOfShading, s as parseDefinition, t as STYLE_NAMES, u as DEFAULT_DEFINITION, v as LEAF_TYPES, y as MAX_BRANCH_LEVELS } from "./names-C6-wuJ29.js";
2
+ import { A as hashTreeData, B as sampleTrack, C as loadTexture, D as clampGrowth, E as textureReady, F as fruitTracks, G as wrapSeason, H as segmentWeight, I as hexToLinear, K as createRandom, L as leafSeason, M as evaluateSeason, N as fruitSeason, O as growPositions, P as fruitSeasonAttribute, R as leafSeasonAttribute, S as getTextureOptions, T as setTextureOptions, U as srgbToLinear, V as seasonShift, W as woodSeasonAttribute, _ as createBarkMaterial, b as BARK_REPEAT, c as Tree, d as sceneWind, f as applySeasonToLeafMaterial, g as assertWebGPURenderer, h as UnsupportedRendererError, i as ForestVariant, j as KEYFRAME_EPSILON, k as hashGeometry, l as WindResponse, m as createSeasonNodes, n as Forest, o as loadStyle, p as createFruitSeasonNodes, r as ForestTree, s as createTree, t as createForest, u as Wind, v as createLeafMaterial, w as resolveTextureUrl, x as DEFAULT_TEXTURE_BASE_PATH, y as isFlatShading, z as partSeasonAt } from "./forest-DTrD8puH.js";
3
3
  import { t as SEASON_PROFILES } from "./profiles-BAiyeFlh.js";
4
4
  import { BufferAttribute, BufferGeometry, Color, DoubleSide, Group, Mesh, MeshStandardMaterial } from "three/webgpu";
5
5
  import { GLTFExporter } from "three/addons/exporters/GLTFExporter.js";
@@ -108,6 +108,38 @@ function bakeLeaves(definition, leaves, growth, season) {
108
108
  visible: (v) => shown[v] === 1
109
109
  }, leaves.indices, isFlatShading(definition.materials.shading));
110
110
  }
111
+ /**
112
+ * Fruit: each Fruit scaled about its attachment point by the Fruit amount (dropped when not
113
+ * shown), then grown; the Fruit colour × the Seed's tint as vertex colours. Same order as the shader.
114
+ */
115
+ function bakeFruit(definition, fruit, growth, season) {
116
+ const count = fruit.positions.length / 3;
117
+ if (count === 0) return null;
118
+ const aSeason = fruit.attributes.aSeason.array;
119
+ const aOrigin = fruit.attributes.aOrigin.array;
120
+ const shown = new Uint8Array(count);
121
+ const colors = new Float32Array(count * 3);
122
+ const scaled = new Float32Array(count * 3);
123
+ for (let v = 0; v < count; v++) {
124
+ const state = fruitSeason(definition.season, season, partSeasonAt(aSeason, v));
125
+ shown[v] = state.visible ? 1 : 0;
126
+ for (let c = 0; c < 3; c++) {
127
+ const i = v * 3 + c;
128
+ colors[i] = state.color[c] * (fruit.colors?.[i] ?? 1);
129
+ scaled[i] = aOrigin[i] + (fruit.positions[i] - aOrigin[i]) * state.scale;
130
+ }
131
+ }
132
+ return compact({
133
+ positions: growPositions({
134
+ ...fruit,
135
+ positions: scaled
136
+ }, growth),
137
+ normals: fruit.normals,
138
+ uvs: fruit.uvs,
139
+ colors,
140
+ visible: (v) => shown[v] === 1
141
+ }, fruit.indices, isFlatShading(definition.materials.shading));
142
+ }
111
143
  /** A loaded texture for the baked material (a copy, so the tree's shared texture is untouched); null without image data. */
112
144
  function bakedMap(texture, repeat) {
113
145
  if (!texture?.image) return null;
@@ -117,7 +149,7 @@ function bakedMap(texture, repeat) {
117
149
  }
118
150
  /**
119
151
  * Freezes a tree at a Growth and Season (default: the tree's own) into a static `Group` of
120
- * meshes `wood` and `leaves` (a mesh with nothing to show is left out) with standard PBR
152
+ * meshes `wood`, `leaves` and `fruit` (a mesh with nothing to show is left out) with standard PBR
121
153
  * materials: no node materials, no Growth/Season/Wind attributes, no animation. The result is
122
154
  * independent of `tree`; call `disposeBakedTree` when done with it.
123
155
  */
@@ -165,6 +197,18 @@ function bakeTree(tree, options = {}) {
165
197
  });
166
198
  group.add(bakedMesh("leaves", leafGeometry, material));
167
199
  }
200
+ const fruitGeometry = bakeFruit(definition, data.fruit, growth, season);
201
+ if (fruitGeometry) {
202
+ const material = new MeshStandardMaterial({
203
+ name: "fruit",
204
+ color: 16777215,
205
+ roughness: tree.fruit.material.roughness,
206
+ metalness: 0,
207
+ vertexColors: true,
208
+ flatShading: flat
209
+ });
210
+ group.add(bakedMesh("fruit", fruitGeometry, material));
211
+ }
168
212
  return group;
169
213
  }
170
214
  function bakedMesh(name, geometry, material) {
@@ -193,6 +237,6 @@ async function exportBakedTree(tree, options = {}) {
193
237
  disposeBakedTree(baked);
194
238
  }
195
239
  }
196
- export { CURRENT_SCHEMA_VERSION, DEFAULT_BRANCH_LEVEL, DEFAULT_DEFINITION, DEFAULT_TEXTURE_BASE_PATH, Forest, ForestTree, ForestVariant, KEYFRAME_EPSILON, MAX_BRANCH_LEVELS, SEASON_PROFILES, STYLE_NAMES, Tree, TreeDefinitionError, UnsupportedRendererError, Wind, WindResponse, applySeasonToLeafMaterial, assertWebGPURenderer, bakeTree, createBarkMaterial, createForest, createLeafMaterial, createRandom, createSeasonNodes, createTree, disposeBakedTree, evaluateSeason, exportBakedTree, extendDefinition, fetchDefinition, getTextureOptions, hashGeometry, hashTreeData, hexToLinear, leafSeason, leafSeasonAttribute, loadStyle, loadTexture, parseDefinition, partSeasonAt, resolveTextureUrl, sampleTrack, sceneWind, seasonShift, segmentWeight, setTextureOptions, srgbToLinear, textureReady, woodSeasonAttribute, wrapSeason };
240
+ export { BARK_TYPES, CURRENT_SCHEMA_VERSION, DEFAULT_BRANCH_LEVEL, DEFAULT_DEFINITION, DEFAULT_FRUIT, DEFAULT_FRUIT_AMOUNT, DEFAULT_FRUIT_COLOR, DEFAULT_TEXTURE_BASE_PATH, FRUIT_TYPES, Forest, ForestTree, ForestVariant, KEYFRAME_EPSILON, LEAF_TYPES, MAX_BRANCH_LEVELS, SEASON_PROFILES, STYLE_NAMES, Tree, TreeDefinitionError, UnsupportedRendererError, Wind, WindResponse, applySeasonToLeafMaterial, assertWebGPURenderer, bakeTree, coneCurve, createBarkMaterial, createForest, createFruitSeasonNodes, createLeafMaterial, createRandom, createSeasonNodes, createTree, disposeBakedTree, evaluateSeason, exportBakedTree, extendDefinition, fetchDefinition, fruitSeason, fruitSeasonAttribute, fruitTracks, getTextureOptions, hashGeometry, hashTreeData, hexToLinear, leafSeason, leafSeasonAttribute, loadStyle, loadTexture, parseDefinition, partSeasonAt, resolveTextureUrl, sampleTrack, sceneWind, seasonShift, segmentWeight, setTextureOptions, srgbToLinear, styleLabel, styleOfShading, textureReady, woodSeasonAttribute, wrapSeason };
197
241
 
198
242
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":[],"sources":["../src/bake/index.ts"],"sourcesContent":["import {\n BufferAttribute,\n BufferGeometry,\n Color,\n DoubleSide,\n Group,\n Mesh,\n MeshStandardMaterial,\n type Texture,\n} from 'three/webgpu';\nimport { GLTFExporter } from 'three/addons/exporters/GLTFExporter.js';\nimport type { TreeDefinition } from '../definition';\nimport type { GeometryBuffers } from '../generator';\nimport { clampGrowth, growPositions } from '../growth';\nimport { BARK_REPEAT } from '../materials/maps';\nimport { isFlatShading } from '../materials/shading';\nimport { leafSeason, partSeasonAt, wrapSeason } from '../season';\nimport type { Tree } from '../tree';\n\n/**\n * Baked Tree: one tree frozen at a Seed, Growth and Season as plain static geometry with\n * standard PBR materials (`MeshStandardMaterial`, no node materials, no custom attributes), for\n * glTF export and other tools. Growth and Season are evaluated on the CPU with the same models the\n * shaders run (`growPositions`, `leafSeason`); Wind is left out (a Baked Tree stands still).\n */\n\n/** Growth and Season to bake at; each defaults to the tree's current value. */\nexport interface BakeOptions {\n growth?: number;\n season?: number;\n}\n\n/** A triangle with (almost) no area is a part that has not sprouted yet: it is dropped. */\nconst MIN_AREA2 = 1e-16;\n\ninterface BakedBuffers {\n positions: Float32Array;\n normals: Float32Array;\n uvs: Float32Array;\n colors: Float32Array | null;\n /** Per vertex: whether it is shown at all. */\n visible: (v: number) => boolean;\n}\n\n/**\n * Keeps the triangles whose three vertices are visible and that have an area, and only the\n * vertices those triangles use. Returns null when nothing is left (glTF forbids empty meshes).\n */\nfunction compact(buffers: BakedBuffers, indices: Uint32Array, flat: boolean): BufferGeometry | null {\n const { positions } = buffers;\n const kept: number[] = [];\n const remap = new Int32Array(positions.length / 3).fill(-1);\n let count = 0;\n for (let t = 0; t < indices.length; t += 3) {\n const [a, b, c] = [indices[t]!, indices[t + 1]!, indices[t + 2]!];\n if (!buffers.visible(a) || !buffers.visible(b) || !buffers.visible(c)) continue;\n if (area2(positions, a, b, c) < MIN_AREA2) continue;\n for (const v of [a, b, c]) {\n if (remap[v] === -1) remap[v] = count++;\n kept.push(remap[v]!);\n }\n }\n if (kept.length === 0) return null;\n\n const pick = (source: Float32Array, size: number) => {\n const out = new Float32Array(count * size);\n remap.forEach((to, from) => {\n if (to >= 0) out.set(source.subarray(from * size, from * size + size), to * size);\n });\n return out;\n };\n let geometry = new BufferGeometry();\n geometry.setAttribute('position', new BufferAttribute(pick(positions, 3), 3));\n geometry.setAttribute('normal', new BufferAttribute(pick(buffers.normals, 3), 3));\n geometry.setAttribute('uv', new BufferAttribute(pick(buffers.uvs, 2), 2));\n if (buffers.colors) geometry.setAttribute('color', new BufferAttribute(pick(buffers.colors, 3), 3));\n geometry.setIndex(new BufferAttribute(Uint32Array.from(kept), 1));\n if (flat) {\n // glTF has no flat-shading switch: split the vertices and give each face its own normal.\n geometry = geometry.toNonIndexed();\n geometry.computeVertexNormals();\n }\n geometry.computeBoundingBox();\n geometry.computeBoundingSphere();\n return geometry;\n}\n\nfunction area2(p: Float32Array, a: number, b: number, c: number): number {\n const u = [p[b * 3]! - p[a * 3]!, p[b * 3 + 1]! - p[a * 3 + 1]!, p[b * 3 + 2]! - p[a * 3 + 2]!];\n const w = [p[c * 3]! - p[a * 3]!, p[c * 3 + 1]! - p[a * 3 + 1]!, p[c * 3 + 2]! - p[a * 3 + 2]!];\n const x = u[1]! * w[2]! - u[2]! * w[1]!;\n const y = u[2]! * w[0]! - u[0]! * w[2]!;\n const z = u[0]! * w[1]! - u[1]! * w[0]!;\n return x * x + y * y + z * z;\n}\n\n/** Wood: grown positions; the bark's base-to-tip darkening (smooth shading) as vertex colours. */\nfunction bakeWood(definition: TreeDefinition, wood: GeometryBuffers, growth: number): BufferGeometry | null {\n const flat = isFlatShading(definition.materials.shading);\n let colors: Float32Array | null = null;\n if (!flat) {\n // Same as the bark colorNode: mix(base * 0.75, base, sqrt(clamp(uv.y))).\n colors = new Float32Array(wood.positions.length);\n for (let v = 0; v < colors.length / 3; v++) {\n const shade = 0.75 + 0.25 * Math.sqrt(Math.min(Math.max(wood.uvs[v * 2 + 1]!, 0), 1));\n colors.fill(shade, v * 3, v * 3 + 3);\n }\n }\n return compact(\n { positions: growPositions(wood, growth), normals: wood.normals, uvs: wood.uvs, colors, visible: () => true },\n wood.indices,\n flat,\n );\n}\n\n/** Leaves: grown positions; fallen leaves dropped; Season (or blossom) colour × the Seed's tint as vertex colours. */\nfunction bakeLeaves(definition: TreeDefinition, leaves: GeometryBuffers, growth: number, season: number): BufferGeometry | null {\n const count = leaves.positions.length / 3;\n const aSeason = leaves.attributes.aSeason!.array;\n const shown = new Uint8Array(count);\n const colors = new Float32Array(count * 3);\n for (let v = 0; v < count; v++) {\n const state = leafSeason(definition.season, season, partSeasonAt(aSeason, v));\n shown[v] = state.visible ? 1 : 0;\n for (let c = 0; c < 3; c++) colors[v * 3 + c] = state.color[c]! * (leaves.colors?.[v * 3 + c] ?? 1);\n }\n return compact(\n { positions: growPositions(leaves, growth), normals: leaves.normals, uvs: leaves.uvs, colors, visible: (v) => shown[v] === 1 },\n leaves.indices,\n isFlatShading(definition.materials.shading),\n );\n}\n\n/** A loaded texture for the baked material (a copy, so the tree's shared texture is untouched); null without image data. */\nfunction bakedMap(texture: Texture | null | undefined, repeat?: readonly [number, number]): Texture | null {\n if (!texture?.image) return null;\n const copy = texture.clone();\n if (repeat) copy.repeat.set(...repeat);\n return copy;\n}\n\n/**\n * Freezes a tree at a Growth and Season (default: the tree's own) into a static `Group` of\n * meshes `wood` and `leaves` (a mesh with nothing to show is left out) with standard PBR\n * materials: no node materials, no Growth/Season/Wind attributes, no animation. The result is\n * independent of `tree`; call `disposeBakedTree` when done with it.\n */\nexport function bakeTree(tree: Tree, options: BakeOptions = {}): Group {\n const { definition, data } = tree;\n const source = tree.wood.material as MeshStandardMaterial; // MeshStandardNodeMaterial: same props\n const growth = clampGrowth(options.growth ?? tree.growth);\n const season = wrapSeason(options.season ?? tree.season);\n const bark = definition.materials.bark;\n const flat = isFlatShading(definition.materials.shading);\n\n const group = new Group();\n group.name = definition.name || 'Tree';\n group.userData = { seed: tree.seed, growth, season };\n\n const woodGeometry = bakeWood(definition, data.wood, growth);\n if (woodGeometry) {\n const material = new MeshStandardMaterial({\n name: 'bark',\n color: new Color(bark.color),\n roughness: bark.roughness,\n metalness: 0,\n vertexColors: woodGeometry.hasAttribute('color'),\n flatShading: flat,\n map: bakedMap(source.map, BARK_REPEAT),\n normalMap: bakedMap(source.normalMap, BARK_REPEAT),\n });\n group.add(bakedMesh('wood', woodGeometry, material));\n }\n\n const leafGeometry = bakeLeaves(definition, data.leaves, growth, season);\n if (leafGeometry) {\n const map = bakedMap(tree.leaves.material.map);\n const material = new MeshStandardMaterial({\n name: 'leaves',\n color: 0xffffff,\n roughness: definition.materials.leaf.roughness,\n metalness: 0,\n vertexColors: true,\n flatShading: flat,\n side: DoubleSide,\n map,\n alphaTest: map ? definition.materials.leaf.alphaTest : 0,\n });\n group.add(bakedMesh('leaves', leafGeometry, material));\n }\n return group;\n}\n\nfunction bakedMesh(name: string, geometry: BufferGeometry, material: MeshStandardMaterial): Mesh {\n const mesh = new Mesh(geometry, material);\n mesh.name = name;\n mesh.castShadow = mesh.receiveShadow = true;\n return mesh;\n}\n\n/** Frees the geometries, materials and texture copies of a baked tree. */\nexport function disposeBakedTree(baked: Group): void {\n baked.traverse((object) => {\n if (!(object instanceof Mesh)) return;\n object.geometry.dispose();\n const material = object.material as MeshStandardMaterial;\n material.map?.dispose();\n material.normalMap?.dispose();\n material.dispose();\n });\n}\n\nexport interface ExportBakedTreeOptions extends BakeOptions {\n /** `.glb` (ArrayBuffer, default) or `.gltf` JSON with embedded buffers. */\n binary?: boolean;\n}\n\n/**\n * Bakes a tree (see {@link bakeTree}) and writes it as glTF 2.0: a `.glb` ArrayBuffer by default,\n * or the `.gltf` JSON object with `binary: false`. Waits for the tree's textures first. In Node,\n * three's GLTFExporter needs a `FileReader` global.\n */\nexport function exportBakedTree(tree: Tree, options?: ExportBakedTreeOptions & { binary?: true }): Promise<ArrayBuffer>;\nexport function exportBakedTree(tree: Tree, options: ExportBakedTreeOptions & { binary: false }): Promise<Record<string, unknown>>;\nexport function exportBakedTree(tree: Tree, options?: ExportBakedTreeOptions): Promise<ArrayBuffer | Record<string, unknown>>;\nexport async function exportBakedTree(\n tree: Tree,\n options: ExportBakedTreeOptions = {},\n): Promise<ArrayBuffer | Record<string, unknown>> {\n await tree.ready;\n const baked = bakeTree(tree, options);\n try {\n const result = await new GLTFExporter().parseAsync(baked, { binary: options.binary ?? true });\n return result as ArrayBuffer | Record<string, unknown>;\n } finally {\n disposeBakedTree(baked);\n }\n}\n"],"mappings":";;;;;;;AAiCA,IAAM,YAAY;;;;;AAelB,SAAS,QAAQ,SAAuB,SAAsB,MAAsC;CAClG,MAAM,EAAE,cAAc;CACtB,MAAM,OAAiB,CAAC;CACxB,MAAM,QAAQ,IAAI,WAAW,UAAU,SAAS,CAAC,CAAC,CAAC,KAAK,EAAE;CAC1D,IAAI,QAAQ;CACZ,KAAK,IAAI,IAAI,GAAG,IAAI,QAAQ,QAAQ,KAAK,GAAG;EAC1C,MAAM,CAAC,GAAG,GAAG,KAAK;GAAC,QAAQ;GAAK,QAAQ,IAAI;GAAK,QAAQ,IAAI;EAAG;EAChE,IAAI,CAAC,QAAQ,QAAQ,CAAC,KAAK,CAAC,QAAQ,QAAQ,CAAC,KAAK,CAAC,QAAQ,QAAQ,CAAC,GAAG;EACvE,IAAI,MAAM,WAAW,GAAG,GAAG,CAAC,IAAI,WAAW;EAC3C,KAAK,MAAM,KAAK;GAAC;GAAG;GAAG;EAAC,GAAG;GACzB,IAAI,MAAM,OAAO,IAAI,MAAM,KAAK;GAChC,KA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,MAAM,SAAS,KAAK,OAAO,SAAS,GAAG;EAC7C,MAAM,WAAW,IAAI,qBAAqB;GACxC,MAAM;GACN,OAAO;GACP,WAAW,WAAW,UAAU,KAAK;GACrC,WAAW;GACX,cAAc;GACd,aAAa;GACb,MAAM;GACN;GACA,WAAW,MAAM,WAAW,UAAU,KAAK,YAAY;EACzD,CAAC;EACD,MAAM,IAAI,UAAU,UAAU,cAAc,QAAQ,CAAC;CACvD;CACA,OAAO;AACT;AAEA,SAAS,UAAU,MAAc,UAA0B,UAAsC;CAC/F,MAAM,OAAO,IAAI,KAAK,UAAU,QAAQ;CACxC,KAAK,OAAO;CACZ,KAAK,aAAa,KAAK,gBAAgB;CACvC,OAAO;AACT;;AAGA,SAAgB,iBAAiB,OAAoB;CACnD,MAAM,UAAU,WAAW;EACzB,IAAI,EAAE,kBAAkB,OAAO;EAC/B,OAAO,SAAS,QAAQ;EACxB,MAAM,WAAW,OAAO;EACxB,SAAS,KAAK,QAAQ;EACtB,SAAS,WAAW,QAAQ;EAC5B,SAAS,QAAQ;CACnB,CAAC;AACH;AAeA,eAAsB,gBACpB,MACA,UAAkC,CAAC,GACa;CAChD,MAAM,KAAK;CACX,MAAM,QAAQ,SAAS,MAAM,OAAO;CACpC,IAAI;EAEF,OAAO,MADc,IAAI,aAAa,CAAC,CAAC,WAAW,OAAO,EAAE,QAAQ,QAAQ,UAAU,KAAK,CAAC;CAE9F,UAAU;EACR,iBAAiB,KAAK;CACxB;AACF"}
1
+ {"version":3,"file":"index.js","names":[],"sources":["../src/bake/index.ts"],"sourcesContent":["import {\n BufferAttribute,\n BufferGeometry,\n Color,\n DoubleSide,\n Group,\n Mesh,\n MeshStandardMaterial,\n type Texture,\n} from 'three/webgpu';\nimport { GLTFExporter } from 'three/addons/exporters/GLTFExporter.js';\nimport type { TreeDefinition } from '../definition';\nimport type { GeometryBuffers } from '../generator';\nimport { clampGrowth, growPositions } from '../growth';\nimport { BARK_REPEAT } from '../materials/maps';\nimport { isFlatShading } from '../materials/shading';\nimport { fruitSeason, leafSeason, partSeasonAt, wrapSeason } from '../season';\nimport type { Tree } from '../tree';\n\n/**\n * Baked Tree: one tree frozen at a Seed, Growth and Season as plain static geometry with\n * standard PBR materials (`MeshStandardMaterial`, no node materials, no custom attributes), for\n * glTF export and other tools. Growth and Season are evaluated on the CPU with the same models the\n * shaders run (`growPositions`, `leafSeason`, `fruitSeason`); Wind is left out (a Baked Tree stands still).\n */\n\n/** Growth and Season to bake at; each defaults to the tree's current value. */\nexport interface BakeOptions {\n growth?: number;\n season?: number;\n}\n\n/** A triangle with (almost) no area is a part that has not sprouted yet: it is dropped. */\nconst MIN_AREA2 = 1e-16;\n\ninterface BakedBuffers {\n positions: Float32Array;\n normals: Float32Array;\n uvs: Float32Array;\n colors: Float32Array | null;\n /** Per vertex: whether it is shown at all. */\n visible: (v: number) => boolean;\n}\n\n/**\n * Keeps the triangles whose three vertices are visible and that have an area, and only the\n * vertices those triangles use. Returns null when nothing is left (glTF forbids empty meshes).\n */\nfunction compact(buffers: BakedBuffers, indices: Uint32Array, flat: boolean): BufferGeometry | null {\n const { positions } = buffers;\n const kept: number[] = [];\n const remap = new Int32Array(positions.length / 3).fill(-1);\n let count = 0;\n for (let t = 0; t < indices.length; t += 3) {\n const [a, b, c] = [indices[t]!, indices[t + 1]!, indices[t + 2]!];\n if (!buffers.visible(a) || !buffers.visible(b) || !buffers.visible(c)) continue;\n if (area2(positions, a, b, c) < MIN_AREA2) continue;\n for (const v of [a, b, c]) {\n if (remap[v] === -1) remap[v] = count++;\n kept.push(remap[v]!);\n }\n }\n if (kept.length === 0) return null;\n\n const pick = (source: Float32Array, size: number) => {\n const out = new Float32Array(count * size);\n remap.forEach((to, from) => {\n if (to >= 0) out.set(source.subarray(from * size, from * size + size), to * size);\n });\n return out;\n };\n let geometry = new BufferGeometry();\n geometry.setAttribute('position', new BufferAttribute(pick(positions, 3), 3));\n geometry.setAttribute('normal', new BufferAttribute(pick(buffers.normals, 3), 3));\n geometry.setAttribute('uv', new BufferAttribute(pick(buffers.uvs, 2), 2));\n if (buffers.colors) geometry.setAttribute('color', new BufferAttribute(pick(buffers.colors, 3), 3));\n geometry.setIndex(new BufferAttribute(Uint32Array.from(kept), 1));\n if (flat) {\n // glTF has no flat-shading switch: split the vertices and give each face its own normal.\n geometry = geometry.toNonIndexed();\n geometry.computeVertexNormals();\n }\n geometry.computeBoundingBox();\n geometry.computeBoundingSphere();\n return geometry;\n}\n\nfunction area2(p: Float32Array, a: number, b: number, c: number): number {\n const u = [p[b * 3]! - p[a * 3]!, p[b * 3 + 1]! - p[a * 3 + 1]!, p[b * 3 + 2]! - p[a * 3 + 2]!];\n const w = [p[c * 3]! - p[a * 3]!, p[c * 3 + 1]! - p[a * 3 + 1]!, p[c * 3 + 2]! - p[a * 3 + 2]!];\n const x = u[1]! * w[2]! - u[2]! * w[1]!;\n const y = u[2]! * w[0]! - u[0]! * w[2]!;\n const z = u[0]! * w[1]! - u[1]! * w[0]!;\n return x * x + y * y + z * z;\n}\n\n/** Wood: grown positions; the bark's base-to-tip darkening (smooth shading) as vertex colours. */\nfunction bakeWood(definition: TreeDefinition, wood: GeometryBuffers, growth: number): BufferGeometry | null {\n const flat = isFlatShading(definition.materials.shading);\n let colors: Float32Array | null = null;\n if (!flat) {\n // Same as the bark colorNode: mix(base * 0.75, base, sqrt(clamp(uv.y))).\n colors = new Float32Array(wood.positions.length);\n for (let v = 0; v < colors.length / 3; v++) {\n const shade = 0.75 + 0.25 * Math.sqrt(Math.min(Math.max(wood.uvs[v * 2 + 1]!, 0), 1));\n colors.fill(shade, v * 3, v * 3 + 3);\n }\n }\n return compact(\n { positions: growPositions(wood, growth), normals: wood.normals, uvs: wood.uvs, colors, visible: () => true },\n wood.indices,\n flat,\n );\n}\n\n/** Leaves: grown positions; fallen leaves dropped; Season (or blossom) colour × the Seed's tint as vertex colours. */\nfunction bakeLeaves(definition: TreeDefinition, leaves: GeometryBuffers, growth: number, season: number): BufferGeometry | null {\n const count = leaves.positions.length / 3;\n const aSeason = leaves.attributes.aSeason!.array;\n const shown = new Uint8Array(count);\n const colors = new Float32Array(count * 3);\n for (let v = 0; v < count; v++) {\n const state = leafSeason(definition.season, season, partSeasonAt(aSeason, v));\n shown[v] = state.visible ? 1 : 0;\n for (let c = 0; c < 3; c++) colors[v * 3 + c] = state.color[c]! * (leaves.colors?.[v * 3 + c] ?? 1);\n }\n return compact(\n { positions: growPositions(leaves, growth), normals: leaves.normals, uvs: leaves.uvs, colors, visible: (v) => shown[v] === 1 },\n leaves.indices,\n isFlatShading(definition.materials.shading),\n );\n}\n\n/**\n * Fruit: each Fruit scaled about its attachment point by the Fruit amount (dropped when not\n * shown), then grown; the Fruit colour × the Seed's tint as vertex colours. Same order as the shader.\n */\nfunction bakeFruit(definition: TreeDefinition, fruit: GeometryBuffers, growth: number, season: number): BufferGeometry | null {\n const count = fruit.positions.length / 3;\n if (count === 0) return null;\n const aSeason = fruit.attributes.aSeason!.array;\n const aOrigin = fruit.attributes.aOrigin!.array;\n const shown = new Uint8Array(count);\n const colors = new Float32Array(count * 3);\n const scaled = new Float32Array(count * 3);\n for (let v = 0; v < count; v++) {\n const state = fruitSeason(definition.season, season, partSeasonAt(aSeason, v));\n shown[v] = state.visible ? 1 : 0;\n for (let c = 0; c < 3; c++) {\n const i = v * 3 + c;\n colors[i] = state.color[c]! * (fruit.colors?.[i] ?? 1);\n scaled[i] = aOrigin[i]! + (fruit.positions[i]! - aOrigin[i]!) * state.scale;\n }\n }\n return compact(\n {\n positions: growPositions({ ...fruit, positions: scaled }, growth),\n normals: fruit.normals,\n uvs: fruit.uvs,\n colors,\n visible: (v) => shown[v] === 1,\n },\n fruit.indices,\n isFlatShading(definition.materials.shading),\n );\n}\n\n/** A loaded texture for the baked material (a copy, so the tree's shared texture is untouched); null without image data. */\nfunction bakedMap(texture: Texture | null | undefined, repeat?: readonly [number, number]): Texture | null {\n if (!texture?.image) return null;\n const copy = texture.clone();\n if (repeat) copy.repeat.set(...repeat);\n return copy;\n}\n\n/**\n * Freezes a tree at a Growth and Season (default: the tree's own) into a static `Group` of\n * meshes `wood`, `leaves` and `fruit` (a mesh with nothing to show is left out) with standard PBR\n * materials: no node materials, no Growth/Season/Wind attributes, no animation. The result is\n * independent of `tree`; call `disposeBakedTree` when done with it.\n */\nexport function bakeTree(tree: Tree, options: BakeOptions = {}): Group {\n const { definition, data } = tree;\n const source = tree.wood.material as MeshStandardMaterial; // MeshStandardNodeMaterial: same props\n const growth = clampGrowth(options.growth ?? tree.growth);\n const season = wrapSeason(options.season ?? tree.season);\n const bark = definition.materials.bark;\n const flat = isFlatShading(definition.materials.shading);\n\n const group = new Group();\n group.name = definition.name || 'Tree';\n group.userData = { seed: tree.seed, growth, season };\n\n const woodGeometry = bakeWood(definition, data.wood, growth);\n if (woodGeometry) {\n const material = new MeshStandardMaterial({\n name: 'bark',\n color: new Color(bark.color),\n roughness: bark.roughness,\n metalness: 0,\n vertexColors: woodGeometry.hasAttribute('color'),\n flatShading: flat,\n map: bakedMap(source.map, BARK_REPEAT),\n normalMap: bakedMap(source.normalMap, BARK_REPEAT),\n });\n group.add(bakedMesh('wood', woodGeometry, material));\n }\n\n const leafGeometry = bakeLeaves(definition, data.leaves, growth, season);\n if (leafGeometry) {\n const map = bakedMap(tree.leaves.material.map);\n const material = new MeshStandardMaterial({\n name: 'leaves',\n color: 0xffffff,\n roughness: definition.materials.leaf.roughness,\n metalness: 0,\n vertexColors: true,\n flatShading: flat,\n side: DoubleSide,\n map,\n alphaTest: map ? definition.materials.leaf.alphaTest : 0,\n });\n group.add(bakedMesh('leaves', leafGeometry, material));\n }\n\n const fruitGeometry = bakeFruit(definition, data.fruit, growth, season);\n if (fruitGeometry) {\n const material = new MeshStandardMaterial({\n name: 'fruit',\n color: 0xffffff,\n roughness: tree.fruit.material.roughness,\n metalness: 0,\n vertexColors: true,\n flatShading: flat,\n });\n group.add(bakedMesh('fruit', fruitGeometry, material));\n }\n return group;\n}\n\nfunction bakedMesh(name: string, geometry: BufferGeometry, material: MeshStandardMaterial): Mesh {\n const mesh = new Mesh(geometry, material);\n mesh.name = name;\n mesh.castShadow = mesh.receiveShadow = true;\n return mesh;\n}\n\n/** Frees the geometries, materials and texture copies of a baked tree. */\nexport function disposeBakedTree(baked: Group): void {\n baked.traverse((object) => {\n if (!(object instanceof Mesh)) return;\n object.geometry.dispose();\n const material = object.material as MeshStandardMaterial;\n material.map?.dispose();\n material.normalMap?.dispose();\n material.dispose();\n });\n}\n\nexport interface ExportBakedTreeOptions extends BakeOptions {\n /** `.glb` (ArrayBuffer, default) or `.gltf` JSON with embedded buffers. */\n binary?: boolean;\n}\n\n/**\n * Bakes a tree (see {@link bakeTree}) and writes it as glTF 2.0: a `.glb` ArrayBuffer by default,\n * or the `.gltf` JSON object with `binary: false`. Waits for the tree's textures first. In Node,\n * three's GLTFExporter needs a `FileReader` global.\n */\nexport function exportBakedTree(tree: Tree, options?: ExportBakedTreeOptions & { binary?: true }): Promise<ArrayBuffer>;\nexport function exportBakedTree(tree: Tree, options: ExportBakedTreeOptions & { binary: false }): Promise<Record<string, unknown>>;\nexport function exportBakedTree(tree: Tree, options?: ExportBakedTreeOptions): Promise<ArrayBuffer | Record<string, unknown>>;\nexport async function exportBakedTree(\n tree: Tree,\n options: ExportBakedTreeOptions = {},\n): Promise<ArrayBuffer | Record<string, unknown>> {\n await tree.ready;\n const baked = bakeTree(tree, options);\n try {\n const result = await new GLTFExporter().parseAsync(baked, { binary: options.binary ?? true });\n return result as ArrayBuffer | Record<string, unknown>;\n } finally {\n disposeBakedTree(baked);\n }\n}\n"],"mappings":";;;;;;;AAiCA,IAAM,YAAY;;;;;AAelB,SAAS,QAAQ,SAAuB,SAAsB,MAAsC;CAClG,MAAM,EAAE,cAAc;CACtB,MAAM,OAAiB,CAAC;CACxB,MAAM,QAAQ,IAAI,WAAW,UAAU,SAAS,CAAC,CAAC,CAAC,KAAK,EAAE;CAC1D,IAAI,QAAQ;CACZ,KAAK,IAAI,IAA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B;AACF"}
@@ -15,4 +15,10 @@ export declare function createBarkMaterial(definition: TreeDefinition, textures?
15
15
  * and by the leaf card texture (`materials.leaf.map`, alpha cut at `alphaTest`), if any.
16
16
  */
17
17
  export declare function createLeafMaterial(definition: TreeDefinition, textures?: TextureOptions): MeshStandardNodeMaterial;
18
+ /**
19
+ * Fruit material: the Definition's shading (flat facets in low-poly, smooth toon in stylized,
20
+ * smooth PBR in realistic), no textures. `.color` is the Fruit colour at Season 0; `Tree` sets the
21
+ * Season colour (`createFruitSeasonNodes`), multiplied by the per-Fruit vertex colours (the Seed's tint).
22
+ */
23
+ export declare function createFruitMaterial(definition: TreeDefinition): MeshStandardNodeMaterial;
18
24
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/materials/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAEzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAIlD,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAEjD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,cAAc,EAAE,QAAQ,CAAC,EAAE,cAAc,GAAG,wBAAwB,CAalH;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,cAAc,EAAE,QAAQ,CAAC,EAAE,cAAc,GAAG,wBAAwB,CAWlH"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/materials/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,KAAK,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAEzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAIlD,OAAO,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAEjD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,cAAc,EAAE,QAAQ,CAAC,EAAE,cAAc,GAAG,wBAAwB,CAalH;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,cAAc,EAAE,QAAQ,CAAC,EAAE,cAAc,GAAG,wBAAwB,CAWlH;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,cAAc,GAAG,wBAAwB,CASxF"}