webgpu-biome 0.0.0-stage → 0.1.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 (79) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +89 -2
  3. package/lib/canopy.d.ts +75 -0
  4. package/lib/canopy.d.ts.map +1 -0
  5. package/lib/canopy.js +295 -0
  6. package/lib/canopy.js.map +1 -0
  7. package/lib/climate.d.ts +68 -0
  8. package/lib/climate.d.ts.map +1 -0
  9. package/lib/climate.js +105 -0
  10. package/lib/climate.js.map +1 -0
  11. package/lib/detail.d.ts +55 -0
  12. package/lib/detail.d.ts.map +1 -0
  13. package/lib/detail.js +225 -0
  14. package/lib/detail.js.map +1 -0
  15. package/lib/ecotone.d.ts +166 -0
  16. package/lib/ecotone.d.ts.map +1 -0
  17. package/lib/ecotone.js +1007 -0
  18. package/lib/ecotone.js.map +1 -0
  19. package/lib/engine.d.ts +102 -0
  20. package/lib/engine.d.ts.map +1 -0
  21. package/lib/engine.js +773 -0
  22. package/lib/engine.js.map +1 -0
  23. package/lib/epiphytes.d.ts +19 -0
  24. package/lib/epiphytes.d.ts.map +1 -0
  25. package/lib/epiphytes.js +180 -0
  26. package/lib/epiphytes.js.map +1 -0
  27. package/lib/ground.d.ts +43 -0
  28. package/lib/ground.d.ts.map +1 -0
  29. package/lib/ground.js +450 -0
  30. package/lib/ground.js.map +1 -0
  31. package/lib/horizon.d.ts +20 -0
  32. package/lib/horizon.d.ts.map +1 -0
  33. package/lib/horizon.js +625 -0
  34. package/lib/horizon.js.map +1 -0
  35. package/lib/index.d.ts +21 -0
  36. package/lib/index.d.ts.map +1 -0
  37. package/lib/index.js +18 -0
  38. package/lib/index.js.map +1 -0
  39. package/lib/particles.d.ts +12 -0
  40. package/lib/particles.d.ts.map +1 -0
  41. package/lib/particles.js +124 -0
  42. package/lib/particles.js.map +1 -0
  43. package/lib/post.d.ts +23 -0
  44. package/lib/post.d.ts.map +1 -0
  45. package/lib/post.js +225 -0
  46. package/lib/post.js.map +1 -0
  47. package/lib/recipe-specs.d.ts +51 -0
  48. package/lib/recipe-specs.d.ts.map +1 -0
  49. package/lib/recipe-specs.js +562 -0
  50. package/lib/recipe-specs.js.map +1 -0
  51. package/lib/recipes.d.ts +9 -0
  52. package/lib/recipes.d.ts.map +1 -0
  53. package/lib/recipes.js +279 -0
  54. package/lib/recipes.js.map +1 -0
  55. package/lib/sandbox.d.ts +183 -0
  56. package/lib/sandbox.d.ts.map +1 -0
  57. package/lib/sandbox.js +1060 -0
  58. package/lib/sandbox.js.map +1 -0
  59. package/lib/shadows.d.ts +71 -0
  60. package/lib/shadows.d.ts.map +1 -0
  61. package/lib/shadows.js +532 -0
  62. package/lib/shadows.js.map +1 -0
  63. package/lib/sky.d.ts +16 -0
  64. package/lib/sky.d.ts.map +1 -0
  65. package/lib/sky.js +132 -0
  66. package/lib/sky.js.map +1 -0
  67. package/lib/substrate.d.ts +124 -0
  68. package/lib/substrate.d.ts.map +1 -0
  69. package/lib/substrate.js +988 -0
  70. package/lib/substrate.js.map +1 -0
  71. package/lib/turf.d.ts +60 -0
  72. package/lib/turf.d.ts.map +1 -0
  73. package/lib/turf.js +278 -0
  74. package/lib/turf.js.map +1 -0
  75. package/lib/water.d.ts +41 -0
  76. package/lib/water.d.ts.map +1 -0
  77. package/lib/water.js +210 -0
  78. package/lib/water.js.map +1 -0
  79. package/package.json +63 -3
@@ -0,0 +1,183 @@
1
+ import { type TreeSpecies } from "webgpu-trees";
2
+ import { type EcotoneRules, type SolvedBiome } from "./ecotone.js";
3
+ import { type SubstrateGrid } from "./substrate.js";
4
+ export type PlantStage = "sapling" | "young" | "mid" | "mature";
5
+ export interface SandboxTreeRecord {
6
+ x: number;
7
+ y: number;
8
+ z: number;
9
+ speciesIndex: number;
10
+ height: number;
11
+ crownRadius: number;
12
+ crownBase: number;
13
+ trunkRadius: number;
14
+ yaw: number;
15
+ seed: number;
16
+ ageYears: number;
17
+ coppiced: boolean;
18
+ dna: string;
19
+ generation: number;
20
+ /** World-space lean (`sin` of the angle) along x and z. It stays with this tree through edits and snapshots. */
21
+ leanX: number;
22
+ leanZ: number;
23
+ /** A shrub-mantle stem or sapling: the ground round it gets a collar that shade-tolerant turf favours. */
24
+ collar: boolean;
25
+ }
26
+ export interface MycorrhizaPatch {
27
+ x: number;
28
+ z: number;
29
+ radius: number;
30
+ strength: number;
31
+ }
32
+ export interface SandboxActionResult {
33
+ ok: boolean;
34
+ action: string;
35
+ year: number;
36
+ note: string;
37
+ changedTrees: boolean;
38
+ changedFlora: boolean;
39
+ treeCount: number;
40
+ floraCount: number;
41
+ meanShelter: number;
42
+ maxGeneration: number;
43
+ wildHybridCount: number;
44
+ localShelter?: number;
45
+ }
46
+ export interface CreateBiomeSandboxOptions {
47
+ baseSubstrate: SubstrateGrid;
48
+ rules: EcotoneRules;
49
+ initialSolved: SolvedBiome;
50
+ treeSpecies?: readonly TreeSpecies[];
51
+ foliageRetention?: number;
52
+ mapCell?: number;
53
+ canopyCell?: number;
54
+ seed?: number;
55
+ onChange?: (res: SandboxActionResult, solved: SolvedBiome) => void;
56
+ }
57
+ export interface PlantTreeOptions {
58
+ x: number;
59
+ z: number;
60
+ species?: string | number;
61
+ customSpecies?: TreeSpecies;
62
+ dna?: string;
63
+ cultivarName?: string;
64
+ stage?: PlantStage;
65
+ yaw?: number;
66
+ seed?: number;
67
+ }
68
+ export interface PlantFloraOptions {
69
+ x: number;
70
+ z: number;
71
+ speciesId: string;
72
+ count?: number;
73
+ colonyRadius?: number;
74
+ seed?: number;
75
+ }
76
+ export interface InoculateMycorrhizaOptions {
77
+ x: number;
78
+ z: number;
79
+ radius?: number;
80
+ strength?: number;
81
+ seed?: number;
82
+ }
83
+ export interface TreeEditTargetOptions {
84
+ x: number;
85
+ z: number;
86
+ radius?: number;
87
+ }
88
+ export interface ManualFloraSnapshot {
89
+ x: number;
90
+ y: number;
91
+ z: number;
92
+ speciesIndex: number;
93
+ height: number;
94
+ radius: number;
95
+ yaw: number;
96
+ seed: number;
97
+ birthYear: number;
98
+ suppressesTurf: boolean;
99
+ isDeadwood: boolean;
100
+ }
101
+ export interface SandboxTreeInspection {
102
+ index: number;
103
+ record: SandboxTreeRecord;
104
+ species: TreeSpecies;
105
+ fitness: number;
106
+ site: {
107
+ shelter: number;
108
+ moisture: number;
109
+ soilPh: number;
110
+ exposure: number;
111
+ };
112
+ }
113
+ /**
114
+ * Version 2 adds `leanX`, `leanZ`, and `collar` to each tree. A version 1 snapshot still opens: each of
115
+ * its trees that stands where a tree of the initial solve stands takes that tree's lean and collar, and
116
+ * any other tree stands upright without a collar.
117
+ */
118
+ export interface BiomeSandboxSnapshot {
119
+ version: 1 | 2;
120
+ recipeId?: string;
121
+ year: number;
122
+ actionSeq: number;
123
+ seed: number;
124
+ foliageRetention: number;
125
+ cultivars: Array<{
126
+ index: number;
127
+ species: TreeSpecies;
128
+ }>;
129
+ trees: SandboxTreeRecord[];
130
+ manualFlora: ManualFloraSnapshot[];
131
+ mycoPatches: MycorrhizaPatch[];
132
+ }
133
+ export interface BiomeSandbox {
134
+ readonly year: number;
135
+ readonly species: readonly TreeSpecies[];
136
+ readonly solved: SolvedBiome;
137
+ readonly maxGeneration: number;
138
+ readonly wildHybridCount: number;
139
+ setFoliageRetention(retention: number): void;
140
+ /**
141
+ * Call `listener` after every successful action, with its result and the new solve. Returns a function
142
+ * that removes this listener only. Any number may listen; `createBiome` keeps its renderer in sync
143
+ * with its own subscription, which no caller's listener replaces.
144
+ */
145
+ subscribe(listener: (res: SandboxActionResult, solved: SolvedBiome) => void): () => void;
146
+ /**
147
+ * Set (or with no handler, clear) the one listener this method keeps, as `onChange` in the options
148
+ * does. It replaces only the previous `setOnChange` handler: subscribers and the renderer stay connected.
149
+ */
150
+ setOnChange(handler?: (res: SandboxActionResult, solved: SolvedBiome) => void): void;
151
+ registerCultivar(species: TreeSpecies): number;
152
+ plantTree(opts: PlantTreeOptions): SandboxActionResult;
153
+ plantFlora(opts: PlantFloraOptions): SandboxActionResult;
154
+ inoculateMycorrhiza(opts: InoculateMycorrhizaOptions): SandboxActionResult;
155
+ coppiceTree(opts: TreeEditTargetOptions): SandboxActionResult;
156
+ fellTree(opts: TreeEditTargetOptions): SandboxActionResult;
157
+ inspectTree(opts: TreeEditTargetOptions): SandboxTreeInspection | null;
158
+ stepSuccession(years: number): SandboxActionResult;
159
+ exportSnapshot(recipeId?: string): BiomeSandboxSnapshot;
160
+ importSnapshot(snapshot: BiomeSandboxSnapshot): SandboxActionResult;
161
+ reset(): SandboxActionResult;
162
+ }
163
+ /**
164
+ * Create a stateful ecological forest & garden sandbox synced with terrain, canopy, soil,
165
+ * epiphytes, and continuous turf cover.
166
+ */
167
+ export declare function createBiomeSandbox(opts: CreateBiomeSandboxOptions): BiomeSandbox;
168
+ /** One sandbox edit as plain data: what Biome Studio and its MCP tools send (`sandboxActions`). */
169
+ export interface SandboxCommand {
170
+ action: "plantTree" | "plantFlora" | "inoculateMycorrhiza" | "coppiceTree" | "fellTree" | "stepSuccession" | "reset";
171
+ x?: number;
172
+ z?: number;
173
+ species?: string;
174
+ dna?: string;
175
+ stage?: PlantStage;
176
+ speciesId?: string;
177
+ count?: number;
178
+ radius?: number;
179
+ years?: number;
180
+ }
181
+ /** Apply one `SandboxCommand` to a sandbox. Unknown or incomplete commands do nothing and return `null`. */
182
+ export declare function applySandboxCommand(sandbox: BiomeSandbox, act: SandboxCommand): SandboxActionResult | null;
183
+ //# sourceMappingURL=sandbox.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sandbox.d.ts","sourceRoot":"","sources":["../src/sandbox.ts"],"names":[],"mappings":"AAIA,OAAO,EAIL,KAAK,WAAW,EAUjB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAA2B,MAAM,cAAc,CAAC;AAI5F,OAAO,EAAE,KAAK,aAAa,EAAwC,MAAM,gBAAgB,CAAC;AAE1F,MAAM,MAAM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