@casmo/tree.js 0.1.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +312 -16
- package/dist/apply-Cio2t7CZ.js +285 -0
- package/dist/apply-Cio2t7CZ.js.map +1 -0
- package/dist/bake/index.d.ts +44 -5
- package/dist/bake/index.d.ts.map +1 -1
- package/dist/definition/crown-shape.d.ts +9 -0
- package/dist/definition/crown-shape.d.ts.map +1 -0
- package/dist/definition/defaults.d.ts +15 -1
- package/dist/definition/defaults.d.ts.map +1 -1
- package/dist/definition/index.d.ts +4 -3
- package/dist/definition/index.d.ts.map +1 -1
- package/dist/definition/migrations.d.ts +0 -8
- package/dist/definition/migrations.d.ts.map +1 -1
- package/dist/definition/schema.d.ts.map +1 -1
- package/dist/definition/types.d.ts +181 -6
- package/dist/definition/types.d.ts.map +1 -1
- package/dist/effects/mask.d.ts +3 -3
- package/dist/effects/mask.d.ts.map +1 -1
- package/dist/effects.js +3 -3
- package/dist/effects.js.map +1 -1
- package/dist/forest/Forest.d.ts +37 -2
- package/dist/forest/Forest.d.ts.map +1 -1
- package/dist/forest/nodes.d.ts +6 -1
- package/dist/forest/nodes.d.ts.map +1 -1
- package/dist/{forest-OX9WvAwh.js → forest-ChEaWJrf.js} +1763 -684
- package/dist/forest-ChEaWJrf.js.map +1 -0
- package/dist/generator/branches.d.ts +2 -2
- package/dist/generator/branches.d.ts.map +1 -1
- package/dist/generator/crown.d.ts +28 -0
- package/dist/generator/crown.d.ts.map +1 -0
- package/dist/generator/fruit.d.ts +28 -0
- package/dist/generator/fruit.d.ts.map +1 -0
- package/dist/generator/growth.d.ts +1 -1
- package/dist/generator/growth.d.ts.map +1 -1
- package/dist/generator/index.d.ts +5 -4
- package/dist/generator/index.d.ts.map +1 -1
- package/dist/generator/leaf-shapes.d.ts +33 -1
- package/dist/generator/leaf-shapes.d.ts.map +1 -1
- package/dist/generator/mesh.d.ts +10 -2
- package/dist/generator/mesh.d.ts.map +1 -1
- package/dist/generator/occlusion.d.ts +8 -0
- package/dist/generator/occlusion.d.ts.map +1 -0
- package/dist/generator/roots.d.ts +16 -0
- package/dist/generator/roots.d.ts.map +1 -0
- package/dist/generator/trunk.d.ts +16 -2
- package/dist/generator/trunk.d.ts.map +1 -1
- package/dist/generator/types.d.ts +61 -6
- package/dist/generator/types.d.ts.map +1 -1
- package/dist/growth/index.d.ts +1 -1
- package/dist/growth/index.d.ts.map +1 -1
- package/dist/growth/tsl.d.ts +2 -0
- package/dist/growth/tsl.d.ts.map +1 -1
- package/dist/index.d.ts +6 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +274 -24
- package/dist/index.js.map +1 -1
- package/dist/materials/crown-nodes.d.ts +20 -0
- package/dist/materials/crown-nodes.d.ts.map +1 -0
- package/dist/materials/crown-normals.d.ts +17 -0
- package/dist/materials/crown-normals.d.ts.map +1 -0
- package/dist/materials/ground-tint.d.ts +13 -0
- package/dist/materials/ground-tint.d.ts.map +1 -0
- package/dist/materials/index.d.ts +13 -1
- package/dist/materials/index.d.ts.map +1 -1
- package/dist/materials/leaf-translucency-model.d.ts +14 -0
- package/dist/materials/leaf-translucency-model.d.ts.map +1 -0
- package/dist/materials/leaf-translucency.d.ts +73 -0
- package/dist/materials/leaf-translucency.d.ts.map +1 -0
- package/dist/materials/material-features.d.ts +43 -0
- package/dist/materials/material-features.d.ts.map +1 -0
- package/dist/materials/occlusion.d.ts +10 -0
- package/dist/materials/occlusion.d.ts.map +1 -0
- package/dist/materials/toon.d.ts +18 -1
- package/dist/materials/toon.d.ts.map +1 -1
- package/dist/names-BE9he6CS.js +713 -0
- package/dist/names-BE9he6CS.js.map +1 -0
- package/dist/react/Tree.d.ts +5 -2
- package/dist/react/Tree.d.ts.map +1 -1
- package/dist/react.js +10 -6
- package/dist/react.js.map +1 -1
- package/dist/season/nodes.d.ts +16 -0
- package/dist/season/nodes.d.ts.map +1 -1
- package/dist/season/profile.d.ts +26 -0
- package/dist/season/profile.d.ts.map +1 -1
- package/dist/species/almond.js +223 -0
- package/dist/species/almond.js.map +1 -0
- package/dist/species/almond.json +210 -0
- package/dist/species/apple.js +230 -0
- package/dist/species/apple.js.map +1 -0
- package/dist/species/apple.json +220 -0
- package/dist/species/ash.js +187 -0
- package/dist/species/ash.js.map +1 -0
- package/dist/species/ash.json +177 -0
- package/dist/species/beech.js +174 -0
- package/dist/species/beech.js.map +1 -0
- package/dist/species/beech.json +167 -0
- package/dist/species/birch.js +170 -0
- package/dist/species/birch.js.map +1 -0
- package/dist/species/birch.json +163 -0
- package/dist/species/catalog.d.ts +61 -0
- package/dist/species/catalog.d.ts.map +1 -0
- package/dist/species/cedar.js +169 -0
- package/dist/species/cedar.js.map +1 -0
- package/dist/species/cedar.json +168 -0
- package/dist/species/cherry.js +237 -0
- package/dist/species/cherry.js.map +1 -0
- package/dist/species/cherry.json +224 -0
- package/dist/species/chestnut.js +230 -0
- package/dist/species/chestnut.js.map +1 -0
- package/dist/species/chestnut.json +220 -0
- package/dist/species/douglas-fir.js +174 -0
- package/dist/species/douglas-fir.js.map +1 -0
- package/dist/species/douglas-fir.json +170 -0
- package/dist/species/elm.js +173 -0
- package/dist/species/elm.js.map +1 -0
- package/dist/species/elm.json +163 -0
- package/dist/species/hemlock.js +175 -0
- package/dist/species/hemlock.js.map +1 -0
- package/dist/species/hemlock.json +171 -0
- package/dist/species/hickory.js +200 -0
- package/dist/species/hickory.js.map +1 -0
- package/dist/species/hickory.json +192 -0
- package/dist/species/index.d.ts +10 -0
- package/dist/species/index.d.ts.map +1 -0
- package/dist/species/juniper.js +158 -0
- package/dist/species/juniper.js.map +1 -0
- package/dist/species/juniper.json +154 -0
- package/dist/species/loaders.d.ts +7 -0
- package/dist/species/loaders.d.ts.map +1 -0
- package/dist/species/mahogany.js +201 -0
- package/dist/species/mahogany.js.map +1 -0
- package/dist/species/mahogany.json +196 -0
- package/dist/species/maple.js +177 -0
- package/dist/species/maple.js.map +1 -0
- package/dist/species/maple.json +171 -0
- package/dist/species/oak.js +220 -0
- package/dist/species/oak.js.map +1 -0
- package/dist/species/oak.json +212 -0
- package/dist/species/olive.js +189 -0
- package/dist/species/olive.js.map +1 -0
- package/dist/species/olive.json +181 -0
- package/dist/species/peach.js +223 -0
- package/dist/species/peach.js.map +1 -0
- package/dist/species/peach.json +210 -0
- package/dist/species/pear.js +213 -0
- package/dist/species/pear.js.map +1 -0
- package/dist/species/pear.json +200 -0
- package/dist/species/pine.js +163 -0
- package/dist/species/pine.js.map +1 -0
- package/dist/species/pine.json +162 -0
- package/dist/species/plum.js +237 -0
- package/dist/species/plum.js.map +1 -0
- package/dist/species/plum.json +224 -0
- package/dist/species/red-oak.js +220 -0
- package/dist/species/red-oak.js.map +1 -0
- package/dist/species/red-oak.json +212 -0
- package/dist/species/redwood.js +174 -0
- package/dist/species/redwood.js.map +1 -0
- package/dist/species/redwood.json +170 -0
- package/dist/species/sequoia.js +167 -0
- package/dist/species/sequoia.js.map +1 -0
- package/dist/species/sequoia.json +166 -0
- package/dist/species/spruce.js +170 -0
- package/dist/species/spruce.js.map +1 -0
- package/dist/species/spruce.json +166 -0
- package/dist/species/teak.js +166 -0
- package/dist/species/teak.js.map +1 -0
- package/dist/species/teak.json +157 -0
- package/dist/species/types.d.ts +65 -0
- package/dist/species/types.d.ts.map +1 -0
- package/dist/species/walnut.js +220 -0
- package/dist/species/walnut.js.map +1 -0
- package/dist/species/walnut.json +212 -0
- package/dist/species/white-oak.js +213 -0
- package/dist/species/white-oak.js.map +1 -0
- package/dist/species/white-oak.json +208 -0
- package/dist/species.js +160 -0
- package/dist/species.js.map +1 -0
- package/dist/styles/apply.d.ts +12 -0
- package/dist/styles/apply.d.ts.map +1 -0
- package/dist/styles/low-poly/index.d.ts +1 -1
- package/dist/styles/low-poly/index.d.ts.map +1 -1
- package/dist/styles/low-poly.js +13 -10
- package/dist/styles/low-poly.js.map +1 -1
- package/dist/styles/material-features.d.ts +27 -0
- package/dist/styles/material-features.d.ts.map +1 -0
- package/dist/styles/names.d.ts +28 -0
- package/dist/styles/names.d.ts.map +1 -0
- package/dist/styles/realistic/index.d.ts +3 -8
- package/dist/styles/realistic/index.d.ts.map +1 -1
- package/dist/styles/realistic/textures.d.ts +20 -0
- package/dist/styles/realistic/textures.d.ts.map +1 -0
- package/dist/styles/realistic.js +14 -18
- package/dist/styles/realistic.js.map +1 -1
- package/dist/styles/registry.d.ts +2 -13
- package/dist/styles/registry.d.ts.map +1 -1
- package/dist/styles/stylized/index.d.ts +1 -1
- package/dist/styles/stylized/index.d.ts.map +1 -1
- package/dist/styles/stylized.js +13 -10
- package/dist/styles/stylized.js.map +1 -1
- package/dist/styles/types.d.ts +16 -2
- package/dist/styles/types.d.ts.map +1 -1
- package/dist/textures/realistic/bark-fibrous-normal.png +0 -0
- package/dist/textures/realistic/bark-fibrous.png +0 -0
- package/dist/textures/realistic/bark-papery-normal.png +0 -0
- package/dist/textures/realistic/bark-papery.png +0 -0
- package/dist/textures/realistic/bark-plated-normal.png +0 -0
- package/dist/textures/realistic/bark-plated.png +0 -0
- package/dist/textures/realistic/bark-smooth-normal.png +0 -0
- package/dist/textures/realistic/bark-smooth.png +0 -0
- package/dist/textures/realistic/leaf-compound.png +0 -0
- package/dist/textures/realistic/leaf-lobed.png +0 -0
- package/dist/textures/realistic/leaf-palmate.png +0 -0
- package/dist/textures/realistic/scale.png +0 -0
- package/dist/tree/Tree.d.ts +34 -5
- package/dist/tree/Tree.d.ts.map +1 -1
- package/package.json +9 -2
- package/dist/forest-OX9WvAwh.js.map +0 -1
- package/dist/types-BZjHhNz7.js +0 -20
- package/dist/types-BZjHhNz7.js.map +0 -1
|
@@ -11,12 +11,16 @@
|
|
|
11
11
|
* Current Tree Definition schema version. Bump it, and add a migration in `migrations.ts`,
|
|
12
12
|
* whenever the format changes or a generator change would alter existing trees (ADR 0003).
|
|
13
13
|
*/
|
|
14
|
-
export declare const CURRENT_SCHEMA_VERSION =
|
|
14
|
+
export declare const CURRENT_SCHEMA_VERSION = 3;
|
|
15
15
|
/** `#rrggbb` colour string. */
|
|
16
16
|
export type HexColor = string;
|
|
17
17
|
/** [x, y, z] */
|
|
18
18
|
export type Vec3Tuple = [number, number, number];
|
|
19
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* Form: a label that groups trees (a Style's `broadleaf` / `conifer` Definition). It never
|
|
21
|
+
* changes geometry and is not part of the Tree Definition; a crown's shape comes from its
|
|
22
|
+
* Crown Shape curves (ADR 0004).
|
|
23
|
+
*/
|
|
20
24
|
export type TreeForm = 'broadleaf' | 'conifer';
|
|
21
25
|
/** Trunk parameters (branch level 0). */
|
|
22
26
|
export interface TrunkDefinition {
|
|
@@ -34,6 +38,32 @@ export interface TrunkDefinition {
|
|
|
34
38
|
lengthVariation: number;
|
|
35
39
|
/** Seed range: maximum sideways drift per section, as a fraction of the section length (0..1). */
|
|
36
40
|
bend: number;
|
|
41
|
+
/**
|
|
42
|
+
* Number of Stems growing from the ground (integer >= 1). Each Stem is a full trunk with these
|
|
43
|
+
* parameters and the full branch structure; Stem paths are "0", "1", "2", ... Absent = 1 (a single trunk).
|
|
44
|
+
*/
|
|
45
|
+
stems?: number;
|
|
46
|
+
/**
|
|
47
|
+
* How far each Stem leans out from vertical, degrees (0..90). The Seed varies it per Stem
|
|
48
|
+
* (± 30 %) and turns the ring of Stems. Absent = 0 (upright).
|
|
49
|
+
*/
|
|
50
|
+
spread?: number;
|
|
51
|
+
/**
|
|
52
|
+
* Pull on the leader, the upper third of each Stem (−1..1): − makes it nod over (a hemlock's
|
|
53
|
+
* drooping tip), + pulls a leaning Stem back up. The lower trunk is never bent. Absent = 0 (none).
|
|
54
|
+
*/
|
|
55
|
+
gravity?: number;
|
|
56
|
+
/**
|
|
57
|
+
* Root Flare (0..1): how much each Stem widens towards the ground over the bottom of its length.
|
|
58
|
+
* 1 makes the base ring 1.8 × the trunk radius. Geometry only (ADR 0007): branches, leaves, Fruit,
|
|
59
|
+
* Growth, Wind and Sculpts never move. Absent = 0 (none).
|
|
60
|
+
*/
|
|
61
|
+
flare?: number;
|
|
62
|
+
/**
|
|
63
|
+
* Number of extra sections the trunk sweep puts in the Root Flare (integer >= 1), set by the Style
|
|
64
|
+
* like `sides` and `sections`: 2 in low-poly, 3 in the others. Unused without flare. Absent = 3.
|
|
65
|
+
*/
|
|
66
|
+
flareSections?: number;
|
|
37
67
|
}
|
|
38
68
|
/**
|
|
39
69
|
* One level of branching. `branches[0]` grows from the trunk, `branches[1]` from the
|
|
@@ -68,6 +98,14 @@ export interface BranchLevelDefinition {
|
|
|
68
98
|
bend: number;
|
|
69
99
|
/** Upward (+) or downward (−) pull on the branch tip (−1..1). */
|
|
70
100
|
gravity: number;
|
|
101
|
+
/**
|
|
102
|
+
* Crown Shape: multiplies `length` by the attach position on the parent (`t` 0 = base .. 1 = tip),
|
|
103
|
+
* values >= 0. Linear between keyframes, holding the first/last value outside them. Absent = flat (1).
|
|
104
|
+
* E.g. a cone: `[{ t: start, value: 1 }, { t: 1, value: 0.1 }]`.
|
|
105
|
+
*/
|
|
106
|
+
lengthProfile?: Keyframe<number>[];
|
|
107
|
+
/** Crown Shape: multiplies `angle` by the attach position on the parent, like `lengthProfile` (values >= 0; the angle stays <= 180). */
|
|
108
|
+
angleProfile?: Keyframe<number>[];
|
|
71
109
|
}
|
|
72
110
|
/** Maximum number of branching levels below the trunk. */
|
|
73
111
|
export declare const MAX_BRANCH_LEVELS = 4;
|
|
@@ -76,8 +114,24 @@ export declare const MAX_BRANCH_LEVELS = 4;
|
|
|
76
114
|
* (a smooth round ball of foliage, for toon shading).
|
|
77
115
|
*/
|
|
78
116
|
export type LeafShape = 'card' | 'clump' | 'needle' | 'puff';
|
|
117
|
+
/**
|
|
118
|
+
* Leaf Type: the kind of leaf a Species has. Each Style decides how to draw it (leaf shape,
|
|
119
|
+
* count, size, texture); in a Tree Definition it is a label that never changes geometry by itself.
|
|
120
|
+
*/
|
|
121
|
+
export type LeafType = 'broad' | 'lobed' | 'palmate' | 'compound' | 'needle' | 'scale';
|
|
122
|
+
/** All Leaf Types. */
|
|
123
|
+
export declare const LEAF_TYPES: readonly LeafType[];
|
|
124
|
+
/**
|
|
125
|
+
* Bark Type: the kind of bark surface a Species has. Each Style decides how to draw it (colour
|
|
126
|
+
* only, or a texture); in a Tree Definition it is a label that never changes geometry by itself.
|
|
127
|
+
*/
|
|
128
|
+
export type BarkType = 'furrowed' | 'smooth' | 'papery' | 'fibrous' | 'plated';
|
|
129
|
+
/** All Bark Types. */
|
|
130
|
+
export declare const BARK_TYPES: readonly BarkType[];
|
|
79
131
|
/** Leaves, placed on the last branching level (or the trunk if there are no branches). */
|
|
80
132
|
export interface LeavesDefinition {
|
|
133
|
+
/** Leaf Type the leaves were drawn from (set by `Style.apply`), so a Style can be re-applied. Optional. */
|
|
134
|
+
type?: LeafType;
|
|
81
135
|
/** Leaves per terminal branch (integer >= 0; 0 = no leaves). */
|
|
82
136
|
count: number;
|
|
83
137
|
/** Leaf shape. */
|
|
@@ -91,9 +145,67 @@ export interface LeavesDefinition {
|
|
|
91
145
|
/** Angle between branch and leaf, degrees (0..180). */
|
|
92
146
|
angle: number;
|
|
93
147
|
}
|
|
148
|
+
/**
|
|
149
|
+
* Fruit Type: the kind of Fruit a tree bears. `round` (apple, cherry, plum), `pear`, `nut` (a
|
|
150
|
+
* spiky husk, e.g. chestnut), `cone` (conifer cones) or `berry` (small, e.g. juniper).
|
|
151
|
+
*/
|
|
152
|
+
export type FruitType = 'round' | 'pear' | 'nut' | 'cone' | 'berry';
|
|
153
|
+
/** Every Fruit Type. */
|
|
154
|
+
export declare const FRUIT_TYPES: readonly FruitType[];
|
|
155
|
+
/**
|
|
156
|
+
* Fruit (ADR 0006): its own tree part, grown on the outermost twigs (the trunk if there are no
|
|
157
|
+
* branch levels) from its own random stream, drawn as small solid shapes in the `fruit` mesh.
|
|
158
|
+
* Absent = no Fruit. Season comes from the Season Profile's `fruit` and `fruitColor` tracks.
|
|
159
|
+
*/
|
|
160
|
+
export interface FruitDefinition {
|
|
161
|
+
/** Fruit Type (shape). */
|
|
162
|
+
type: FruitType;
|
|
163
|
+
/**
|
|
164
|
+
* Fruit per outermost twig (>= 0). A fraction is a chance: 0.3 = one Fruit on about 30% of the
|
|
165
|
+
* twigs, 1.5 = one on every twig and a second on about half (which twigs comes from the Seed).
|
|
166
|
+
*/
|
|
167
|
+
count: number;
|
|
168
|
+
/** Fruit length (and about its diameter), metres (> 0). */
|
|
169
|
+
size: number;
|
|
170
|
+
/** Seed range: ± this fraction of `size` (0..1). */
|
|
171
|
+
sizeVariation: number;
|
|
172
|
+
/** How far the Fruit dangles below its twig (0 = sits on the twig pointing outward .. 1 = hangs straight down). */
|
|
173
|
+
hang: number;
|
|
174
|
+
/**
|
|
175
|
+
* Polygon detail, set by the Style: faces around each Fruit (3..16). 5 or fewer also gives a coarse
|
|
176
|
+
* profile (a few flat facets, low-poly). Absent = the Fruit Type's own smooth template.
|
|
177
|
+
*/
|
|
178
|
+
sides?: number;
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Roots (ADR 0007): their own tree part, grown after the Sculpt pass from the Root Flare of every
|
|
182
|
+
* remaining Stem, each from its own random stream, and drawn in the wood mesh after the branches.
|
|
183
|
+
* They run outward and down, taper to a point below the ground, grow with the trunk and never sway.
|
|
184
|
+
* They are not Sculptable. Absent = no Roots.
|
|
185
|
+
*/
|
|
186
|
+
export interface RootsDefinition {
|
|
187
|
+
/** Roots per Stem (integer 0..12). */
|
|
188
|
+
count: number;
|
|
189
|
+
/** Root length as a fraction of its Stem's length (after Seed variation and Sculpts), 0..1. */
|
|
190
|
+
length: number;
|
|
191
|
+
/** Seed range: ± this fraction of `length` (0..1). */
|
|
192
|
+
lengthVariation: number;
|
|
193
|
+
/** Base radius as a fraction of the trunk's base radius (0..1). */
|
|
194
|
+
radius: number;
|
|
195
|
+
/** How steeply a Root dives, degrees below horizontal (0..60). Every Root still ends below the ground. */
|
|
196
|
+
angle: number;
|
|
197
|
+
/** Seed range: sideways wander per section (0..1). */
|
|
198
|
+
bend: number;
|
|
199
|
+
/** Polygon detail, set by the Style: sides around each Root (integer 3..16). Absent = derived from `trunk.sides`. */
|
|
200
|
+
sides?: number;
|
|
201
|
+
/** Polygon detail, set by the Style: sections along each Root (integer >= 1). Absent = 4. */
|
|
202
|
+
sections?: number;
|
|
203
|
+
}
|
|
94
204
|
/** Material shading model. Low-poly uses `flat`, stylized `toon`, realistic `standard`. */
|
|
95
205
|
export type Shading = 'standard' | 'flat' | 'toon';
|
|
96
206
|
export interface BarkMaterialDefinition {
|
|
207
|
+
/** Bark Type the bark was drawn from (set by `Style.apply`), so a Style can be re-applied. Optional. */
|
|
208
|
+
type?: BarkType;
|
|
97
209
|
/** Base bark colour. */
|
|
98
210
|
color: HexColor;
|
|
99
211
|
/** PBR roughness (0..1). */
|
|
@@ -102,6 +214,20 @@ export interface BarkMaterialDefinition {
|
|
|
102
214
|
map: string | null;
|
|
103
215
|
/** Normal map URL, or null for none. */
|
|
104
216
|
normalMap: string | null;
|
|
217
|
+
/** Ground Tint: a darker or mossy bark colour near the ground. Optional; absent = none. */
|
|
218
|
+
groundTint?: GroundTintDefinition;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Ground Tint: at and below the ground (tree-space height <= 0, measured on the grown tree) the
|
|
222
|
+
* bark colour blends towards `color` by `strength`; the blend fades smoothly to nothing at `height`.
|
|
223
|
+
*/
|
|
224
|
+
export interface GroundTintDefinition {
|
|
225
|
+
/** The colour the bark blends towards near the ground. */
|
|
226
|
+
color: HexColor;
|
|
227
|
+
/** Metres above the ground where the tint has faded out (> 0). */
|
|
228
|
+
height: number;
|
|
229
|
+
/** How far the bark blends towards `color` at the ground (0..1). */
|
|
230
|
+
strength: number;
|
|
105
231
|
}
|
|
106
232
|
export interface LeafMaterialDefinition {
|
|
107
233
|
/** PBR roughness (0..1). Leaf colour comes from the Season Profile. */
|
|
@@ -110,13 +236,51 @@ export interface LeafMaterialDefinition {
|
|
|
110
236
|
map: string | null;
|
|
111
237
|
/** Alpha cut-off for `map` (0..1). */
|
|
112
238
|
alphaTest: number;
|
|
239
|
+
/**
|
|
240
|
+
* Crown Normals (a Material Feature, ADR 0008): how far each leaf's normal bends towards the
|
|
241
|
+
* Crown Volume's normal, 0 (each leaf lit on its own) .. 1 (the crown lit as one shape). Absent or 0 = off.
|
|
242
|
+
*/
|
|
243
|
+
crownNormals?: number;
|
|
244
|
+
/** Leaf Translucency (a Material Feature, ADR 0008). Absent = off. */
|
|
245
|
+
translucency?: TranslucencyDefinition;
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Leaf Translucency: light shining through the leaves towards the viewer makes them glow in their
|
|
249
|
+
* own (Season) colour, more at the thin edge of the crown. All plain numbers, 0..1.
|
|
250
|
+
*/
|
|
251
|
+
export interface TranslucencyDefinition {
|
|
252
|
+
/** How strongly leaves with a direct light behind them glow (0..1). */
|
|
253
|
+
strength: number;
|
|
254
|
+
/** Extra glow at the thin edge of the Crown Volume (0 = the same everywhere .. 1 = only at the edge). */
|
|
255
|
+
edge: number;
|
|
256
|
+
/** The indirect (sky) part shining through the canopy, dimmed by occlusion (0..1). */
|
|
257
|
+
ambient: number;
|
|
258
|
+
}
|
|
259
|
+
/** Structural Occlusion: ambient light darkened where the tree hides itself (wood, leaves and Fruit). */
|
|
260
|
+
export interface OcclusionDefinition {
|
|
261
|
+
/** How far the baked occlusion darkens ambient and indirect light (0 = none .. 1 = fully). */
|
|
262
|
+
strength: number;
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* The three Material Features (GLOSSARY, ADR 0008), with the same shapes as in a Definition
|
|
266
|
+
* (`materials.leaf.crownNormals`, `materials.leaf.translucency`, `materials.occlusion`). Absent = off.
|
|
267
|
+
*/
|
|
268
|
+
export interface MaterialFeatures {
|
|
269
|
+
crownNormals?: number;
|
|
270
|
+
translucency?: TranslucencyDefinition;
|
|
271
|
+
occlusion?: OcclusionDefinition;
|
|
113
272
|
}
|
|
114
273
|
export interface MaterialsDefinition {
|
|
115
274
|
shading: Shading;
|
|
116
275
|
bark: BarkMaterialDefinition;
|
|
117
276
|
leaf: LeafMaterialDefinition;
|
|
277
|
+
/** Structural Occlusion (a Material Feature, ADR 0008). Absent = off. */
|
|
278
|
+
occlusion?: OcclusionDefinition;
|
|
118
279
|
}
|
|
119
|
-
/**
|
|
280
|
+
/**
|
|
281
|
+
* One keyframe of a track. In a Season Profile `t` is the Season (0 = first day of spring .. 1 = last
|
|
282
|
+
* day of winter); in a Crown Shape curve it is the attach position on the parent branch (0 = base .. 1 = tip).
|
|
283
|
+
*/
|
|
120
284
|
export interface Keyframe<V> {
|
|
121
285
|
t: number;
|
|
122
286
|
value: V;
|
|
@@ -134,6 +298,13 @@ export interface SeasonProfileDefinition {
|
|
|
134
298
|
blossom: Keyframe<number>[];
|
|
135
299
|
/** Blossom colour. */
|
|
136
300
|
blossomColor: HexColor;
|
|
301
|
+
/**
|
|
302
|
+
* Fruit amount keyframes (0 = none .. 1 = all Fruit at full size); each Fruit shows while the amount
|
|
303
|
+
* is above its own rank and swells with the amount. Absent = 1 all year. Only used with `fruit`.
|
|
304
|
+
*/
|
|
305
|
+
fruit?: Keyframe<number>[];
|
|
306
|
+
/** Fruit colour keyframes (ripening). Absent = a red (`DEFAULT_FRUIT_COLOR`) all year. Only used with `fruit`. */
|
|
307
|
+
fruitColor?: Keyframe<HexColor>[];
|
|
137
308
|
}
|
|
138
309
|
/** Per-tree response to the scene-wide Wind. All 0 (stiff) .. 1 (very flexible). */
|
|
139
310
|
export interface WindResponseDefinition {
|
|
@@ -158,7 +329,7 @@ export interface VariationDefinition {
|
|
|
158
329
|
interface SculptBase {
|
|
159
330
|
/** The Seed the Sculpt was made on; every other Seed ignores it (ADR 0003). */
|
|
160
331
|
seed: number;
|
|
161
|
-
/** Branch path, e.g. "0" (trunk) or "0.3.1". */
|
|
332
|
+
/** Branch path, e.g. "0" (trunk / first Stem), "1" (second Stem) or "0.3.1". */
|
|
162
333
|
path: string;
|
|
163
334
|
}
|
|
164
335
|
/** Removes a branch and everything growing from it. */
|
|
@@ -186,12 +357,16 @@ export interface TreeDefinition {
|
|
|
186
357
|
schemaVersion: typeof CURRENT_SCHEMA_VERSION;
|
|
187
358
|
/** Optional human-readable name. */
|
|
188
359
|
name: string;
|
|
189
|
-
/**
|
|
190
|
-
|
|
360
|
+
/** Id of the Species this Definition was made from by `Style.apply` (e.g. `'oak'`). Optional; never changes geometry. */
|
|
361
|
+
species?: string;
|
|
191
362
|
trunk: TrunkDefinition;
|
|
192
363
|
/** Branching levels below the trunk (0..{@link MAX_BRANCH_LEVELS} entries). */
|
|
193
364
|
branches: BranchLevelDefinition[];
|
|
194
365
|
leaves: LeavesDefinition;
|
|
366
|
+
/** Fruit on the outermost twigs; absent = none. */
|
|
367
|
+
fruit?: FruitDefinition;
|
|
368
|
+
/** Roots on every Stem; absent = none. */
|
|
369
|
+
roots?: RootsDefinition;
|
|
195
370
|
materials: MaterialsDefinition;
|
|
196
371
|
season: SeasonProfileDefinition;
|
|
197
372
|
wind: WindResponseDefinition;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/definition/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;GAGG;AACH,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC,+BAA+B;AAC/B,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE9B,gBAAgB;AAChB,MAAM,MAAM,SAAS,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAEjD
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/definition/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH;;;GAGG;AACH,eAAO,MAAM,sBAAsB,IAAI,CAAC;AAExC,+BAA+B;AAC/B,MAAM,MAAM,QAAQ,GAAG,MAAM,CAAC;AAE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AA;CAAE,GAAG,WAAW,CAAC,IAAI,CAAC,cAAc,EAAE,eAAe,CAAC,CAAC,CAAC"}
|
package/dist/effects/mask.d.ts
CHANGED
|
@@ -2,15 +2,15 @@ import { type Camera, type Material, type MRTNode, type Node, type Object3D, typ
|
|
|
2
2
|
/** Name of the tree mask output in a pass's MRT (`scenePass.getTextureNode(TREE_MASK)`). */
|
|
3
3
|
export declare const TREE_MASK = "treeMask";
|
|
4
4
|
/** The part of a tree a material draws. */
|
|
5
|
-
export type TreePart = 'bark' | 'leaves';
|
|
5
|
+
export type TreePart = 'bark' | 'leaves' | 'fruit';
|
|
6
6
|
/**
|
|
7
|
-
* Which tree part a material draws: 'bark' or '
|
|
7
|
+
* Which tree part a material draws: 'bark', 'leaves' or 'fruit' for tree.js materials (and their clones),
|
|
8
8
|
* `null` for anything else. Tree Effects only change the pixels drawn by these materials.
|
|
9
9
|
*/
|
|
10
10
|
export declare function treePartOf(material: Material | null | undefined): TreePart | null;
|
|
11
11
|
/**
|
|
12
12
|
* TSL node: the tree mask value of the object being drawn, `vec4(tree, leaves, selected, 1)`:
|
|
13
|
-
* r = 1 on tree pixels, g = 1 on leaf pixels, b = 1 on pixels of selected trees (the outline's
|
|
13
|
+
* r = 1 on tree pixels (bark, leaves and Fruit), g = 1 on leaf pixels, b = 1 on pixels of selected trees (the outline's
|
|
14
14
|
* selection), 0 elsewhere. A per-object uniform decided from the drawn material
|
|
15
15
|
* ({@link treePartOf}), so no tree material is changed and every other object writes 0.
|
|
16
16
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mask.d.ts","sourceRoot":"","sources":["../../src/effects/mask.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,MAAM,EACX,KAAK,QAAQ,EACb,KAAK,OAAO,EACZ,KAAK,IAAI,EACT,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,KAAK,EACV,KAAK,WAAW,EACjB,MAAM,cAAc,CAAC;AAGtB,4FAA4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AAG,eAAe,CAK3H"}
|
package/dist/effects.js
CHANGED
|
@@ -5,12 +5,12 @@ import { gaussianBlur } from "three/addons/tsl/display/GaussianBlurNode.js";
|
|
|
5
5
|
/** Name of the tree mask output in a pass's MRT (`scenePass.getTextureNode(TREE_MASK)`). */
|
|
6
6
|
var TREE_MASK = "treeMask";
|
|
7
7
|
/**
|
|
8
|
-
* Which tree part a material draws: 'bark' or '
|
|
8
|
+
* Which tree part a material draws: 'bark', 'leaves' or 'fruit' for tree.js materials (and their clones),
|
|
9
9
|
* `null` for anything else. Tree Effects only change the pixels drawn by these materials.
|
|
10
10
|
*/
|
|
11
11
|
function treePartOf(material) {
|
|
12
12
|
const part = material?.userData.treePart;
|
|
13
|
-
return part === "bark" || part === "leaves" ? part : null;
|
|
13
|
+
return part === "bark" || part === "leaves" || part === "fruit" ? part : null;
|
|
14
14
|
}
|
|
15
15
|
function isSelected(object, selection) {
|
|
16
16
|
for (let o = object; o; o = o.parent) if (selection.includes(o)) return true;
|
|
@@ -18,7 +18,7 @@ function isSelected(object, selection) {
|
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
20
|
* TSL node: the tree mask value of the object being drawn, `vec4(tree, leaves, selected, 1)`:
|
|
21
|
-
* r = 1 on tree pixels, g = 1 on leaf pixels, b = 1 on pixels of selected trees (the outline's
|
|
21
|
+
* r = 1 on tree pixels (bark, leaves and Fruit), g = 1 on leaf pixels, b = 1 on pixels of selected trees (the outline's
|
|
22
22
|
* selection), 0 elsewhere. A per-object uniform decided from the drawn material
|
|
23
23
|
* ({@link treePartOf}), so no tree material is changed and every other object writes 0.
|
|
24
24
|
*
|
package/dist/effects.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"effects.js","names":["tslColor","color","tslColor","color","tslColor","n"],"sources":["../src/effects/mask.ts","../src/effects/outline.ts","../src/effects/glow.ts","../src/effects/grade.ts","../src/effects/suggested.ts","../src/effects/effects.ts"],"sourcesContent":["import {\n UnsignedByteType,\n Vector4,\n type Camera,\n type Material,\n type MRTNode,\n type Node,\n type Object3D,\n type PassNode,\n type Scene,\n type TextureNode,\n} from 'three/webgpu';\nimport { mrt, output, pass, uniform } from 'three/tsl';\n\n/** Name of the tree mask output in a pass's MRT (`scenePass.getTextureNode(TREE_MASK)`). */\nexport const TREE_MASK = 'treeMask';\n\n/** The part of a tree a material draws. */\nexport type TreePart = 'bark' | 'leaves';\n\n/**\n * Which tree part a material draws: 'bark' or 'leaves' for tree.js materials (and their clones),\n * `null` for anything else. Tree Effects only change the pixels drawn by these materials.\n */\nexport function treePartOf(material: Material | null | undefined): TreePart | null {\n const part: unknown = material?.userData.treePart;\n return part === 'bark' || part === 'leaves' ? part : null;\n}\n\nfunction isSelected(object: Object3D | null, selection: readonly Object3D[]): boolean {\n for (let o = object; o; o = o.parent) if (selection.includes(o)) return true;\n return false;\n}\n\n/**\n * TSL node: the tree mask value of the object being drawn, `vec4(tree, leaves, selected, 1)`:\n * r = 1 on tree pixels, g = 1 on leaf pixels, b = 1 on pixels of selected trees (the outline's\n * selection), 0 elsewhere. A per-object uniform decided from the drawn material\n * ({@link treePartOf}), so no tree material is changed and every other object writes 0.\n *\n * `selection`: the selected tree objects (Trees, Forests, any ancestor of tree meshes), read on\n * every draw, so it may be changed in place. `null` (default) selects every tree.\n */\nexport function createTreeMask(selection: readonly Object3D[] | null = null): Node<'vec4'> {\n return uniform(new Vector4(0, 0, 0, 1)).onObjectUpdate((frame, self) => {\n const part = treePartOf(frame.material);\n const selected = part !== null && (selection === null || isSelected(frame.object, selection));\n self.value.set(part ? 1 : 0, part === 'leaves' ? 1 : 0, selected ? 1 : 0, 1);\n return undefined;\n });\n}\n\n/**\n * The MRT output that renders the tree mask ({@link createTreeMask}) next to the colour. Merge it\n * into the MRT of your own scene pass: `scenePass.setMRT(mrt({ output, normal: normalView }).merge(treeMaskMRT()))`,\n * then read it with `scenePass.getTextureNode(TREE_MASK)`.\n */\nexport function treeMaskMRT(selection: readonly Object3D[] | null = null): MRTNode {\n const node = mrt({ [TREE_MASK]: createTreeMask(selection) });\n node.setClearColor(TREE_MASK, 0x000000, 0);\n return node;\n}\n\n/** What every Tree Effect reads: the scene colour and the tree mask (screen-space nodes). */\nexport interface TreeEffectInput {\n /** Scene colour (linear, before tone mapping), e.g. `scenePass.getTextureNode('output')`. */\n color: Node<'vec4'>;\n /** Tree mask texture (see {@link createTreeMask}), e.g. `scenePass.getTextureNode(TREE_MASK)`. */\n mask: TextureNode;\n}\n\n/** A scene pass that renders the colour and the tree mask, ready for the Tree Effects. */\nexport interface TreeEffectsPass extends TreeEffectInput {\n pass: PassNode;\n}\n\n/**\n * Creates `pass(scene, camera)` with MRT `{ output, treeMask }` and returns it with its colour and\n * mask texture nodes. `selection`: the trees to outline (default `null` = all trees), see\n * {@link createTreeMask}. If your pipeline already has a scene pass, merge {@link treeMaskMRT} into it instead.\n */\nexport function treeEffectsPass(scene: Scene, camera: Camera, selection: readonly Object3D[] | null = null): TreeEffectsPass {\n const scenePass = pass(scene, camera);\n scenePass.setMRT(mrt({ output }).merge(treeMaskMRT(selection)));\n scenePass.getTexture(TREE_MASK).type = UnsignedByteType;\n return { pass: scenePass, color: scenePass.getTextureNode('output'), mask: scenePass.getTextureNode(TREE_MASK) };\n}\n","import { Color, type ColorRepresentation, type Node } from 'three/webgpu';\nimport { color as tslColor, float, mix, textureSize, uv, vec2, vec4 } from 'three/tsl';\nimport type { TreeEffectInput } from './mask';\n\n/** Tree outline settings. */\nexport interface TreeOutlineOptions {\n /** Line colour (default a dark green-brown). */\n color?: ColorRepresentation;\n /** Line width in pixels (default 2). */\n thickness?: number;\n /** Opacity of the line, 0..1 (default 1). */\n strength?: number;\n}\n\n// Eight sample directions around a pixel (unit length).\nconst D = Math.SQRT1_2;\nconst DIRECTIONS: [number, number][] = [[1, 0], [-1, 0], [0, 1], [0, -1], [D, D], [D, -D], [-D, D], [-D, -D]];\n\n/**\n * Tree Effect: an outline along the silhouettes of the selected trees (the `selection` of the\n * tree mask, see `createTreeMask`; all trees by default), around the outside of the canopy and\n * the gaps in it. The line is drawn on the inside of the silhouette, so only tree pixels change.\n */\nexport function treeOutline(input: TreeEffectInput, options: TreeOutlineOptions = {}): Node<'vec4'> {\n const { color = '#1d2a14', thickness = 2, strength = 1 } = options;\n const { mask } = input;\n const step = vec2(thickness).div(vec2(textureSize(mask) as unknown as Node<'ivec2'>));\n const centre = uv();\n // Fraction of neighbours (at `thickness` px) that are not selected tree pixels.\n let outside: Node<'float'> = float(0);\n for (const [x, y] of DIRECTIONS) {\n outside = outside.add(float(1).sub(mask.sample(centre.add(step.mul(vec2(x, y)))).b));\n }\n const edge = outside.mul(3 / DIRECTIONS.length).clamp(0, 1).mul(mask.sample(centre).b).mul(strength);\n return vec4(mix(input.color.rgb, tslColor(new Color(color)), edge), input.color.a);\n}\n","import { Color, type ColorRepresentation, type Node } from 'three/webgpu';\nimport { color as tslColor, luminance, smoothstep, vec4 } from 'three/tsl';\nimport { gaussianBlur } from 'three/addons/tsl/display/GaussianBlurNode.js';\nimport type { TreeEffectInput } from './mask';\n\n/** Leaf glow settings. */\nexport interface LeafGlowOptions {\n /** Glow colour, multiplied with the blurred leaf colour (default white). */\n color?: ColorRepresentation;\n /** Glow strength (default 0.6). */\n intensity?: number;\n /** Only leaf pixels brighter than this (linear luminance) glow; 0 = all leaves (default 0.15). */\n threshold?: number;\n /** Blur radius (Gaussian sigma, in pixels at half resolution; default 6). */\n radius?: number;\n}\n\n/**\n * Tree Effect: a soft glow of the leaves. The bright (sunlit) leaf pixels are blurred and added\n * back onto the tree pixels (leaves and the wood between them), never onto the rest of the scene.\n */\nexport function leafGlow(input: TreeEffectInput, options: LeafGlowOptions = {}): Node<'vec4'> {\n const { color = '#ffffff', intensity = 0.6, threshold = 0.15, radius = 6 } = options;\n const bright = smoothstep(threshold, threshold * 2 + 0.05, luminance(input.color.rgb));\n const leaves = vec4(input.color.rgb.mul(input.mask.g).mul(bright), 1);\n const blurred = gaussianBlur(leaves, null, radius, { resolutionScale: 0.5 });\n const glow = blurred.rgb.mul(tslColor(new Color(color))).mul(intensity).mul(input.mask.r);\n return vec4(input.color.rgb.add(glow), input.color.a);\n}\n","import { Color, type ColorRepresentation, type Node } from 'three/webgpu';\nimport { color as tslColor, float, luminance, mix, select, vec3, vec4 } from 'three/tsl';\nimport type { TreeEffectInput } from './mask';\n\n/** Tree colour grading settings (all optional; the defaults change nothing). */\nexport interface TreeColorGradeOptions {\n /** Brightness multiplier (default 1). */\n exposure?: number;\n /** 0 = grey, 1 = unchanged (default), > 1 = more saturated. */\n saturation?: number;\n /** Contrast around mid grey: 1 = unchanged (default), > 1 = more contrast. */\n contrast?: number;\n /** Colour multiplied in, e.g. a warm '#fff2dd' (default white). */\n tint?: ColorRepresentation;\n}\n\nconst MID_GREY = 0.18; // linear\n\n/**\n * Tree Effect: colour grading (exposure, tint, saturation, contrast) of the tree pixels only.\n * Returns the graded colour where the tree mask is set and `input.color` unchanged elsewhere.\n */\nexport function treeColorGrade(input: TreeEffectInput, options: TreeColorGradeOptions = {}): Node<'vec4'> {\n const { exposure = 1, saturation = 1, contrast = 1, tint = '#ffffff' } = options;\n const tinted = input.color.rgb.mul(tslColor(new Color(tint))).mul(exposure);\n const saturated = mix(vec3(luminance(tinted)), tinted, saturation).max(0);\n const contrasted = saturated.div(MID_GREY).pow(vec3(float(contrast))).mul(MID_GREY);\n return select(input.mask.r.greaterThan(0.5), vec4(contrasted, input.color.a), input.color);\n}\n","import type { StyleName } from '../styles/registry';\nimport type { TreeColorGradeOptions } from './grade';\nimport type { LeafGlowOptions } from './glow';\nimport type { TreeOutlineOptions } from './outline';\n\n/** A combination of Tree Effects; leave an effect out to skip it. `{}` = no effects. */\nexport interface TreeEffectsSettings {\n grade?: TreeColorGradeOptions;\n glow?: LeafGlowOptions;\n outline?: TreeOutlineOptions;\n}\n\n/** The suggested combination of Tree Effects for each built-in Style. */\nexport const SUGGESTED_TREE_EFFECTS: Record<StyleName, TreeEffectsSettings> = {\n // Crisp facets: a dark ink line and slightly punchier colours.\n 'low-poly': {\n grade: { saturation: 1.15, contrast: 1.1 },\n outline: { color: '#18230f', thickness: 2, strength: 0.9 },\n },\n // Storybook look: soft glowing foliage, a warm tint and a soft coloured outline.\n stylized: {\n grade: { saturation: 0.95, contrast: 1.08, tint: '#fff1e0' },\n glow: { color: '#fff6c8', intensity: 0.45, threshold: 0.3, radius: 8 },\n outline: { color: '#2b3a1c', thickness: 2, strength: 0.6 },\n },\n // Natural: only a gentle grade (warmer, a touch more contrast) and a faint sunlit leaf glow.\n realistic: {\n grade: { exposure: 1.05, contrast: 1.08, saturation: 0.95, tint: '#fff5e6' },\n glow: { color: '#e8ffc0', intensity: 0.35, threshold: 0.12, radius: 4 },\n },\n};\n","import { RenderPipeline, type Camera, type Node, type Object3D, type Renderer, type Scene } from 'three/webgpu';\nimport type { StyleName } from '../styles/registry';\nimport { leafGlow } from './glow';\nimport { treeColorGrade } from './grade';\nimport { treeEffectsPass, type TreeEffectInput, type TreeEffectsPass } from './mask';\nimport { treeOutline } from './outline';\nimport { SUGGESTED_TREE_EFFECTS, type TreeEffectsSettings } from './suggested';\n\n/**\n * Applies a combination of Tree Effects to `input` and returns the resulting colour node, for use in\n * your own post-processing pipeline (`pipeline.outputNode = applyTreeEffects(...)`, or feed it into\n * more effects). Order: colour grade, leaf glow, outline. Empty settings return `input.color`.\n */\nexport function applyTreeEffects(input: TreeEffectInput, settings: TreeEffectsSettings): Node<'vec4'> {\n let color = input.color;\n if (settings.grade) color = treeColorGrade({ color, mask: input.mask }, settings.grade);\n if (settings.glow) color = leafGlow({ color, mask: input.mask }, settings.glow);\n if (settings.outline) color = treeOutline({ color, mask: input.mask }, settings.outline);\n return color;\n}\n\n/** The suggested combination of a built-in Style, or the settings themselves; `null` = no effects. */\nexport type TreeEffectsChoice = StyleName | TreeEffectsSettings | null;\n\nfunction resolveEffects(choice: TreeEffectsChoice): TreeEffectsSettings {\n if (choice === null) return {};\n if (typeof choice !== 'string') return choice;\n const settings = (SUGGESTED_TREE_EFFECTS as Record<string, TreeEffectsSettings | undefined>)[choice];\n if (!settings) throw new Error(`No suggested Tree Effects for Style \"${choice}\"`);\n return settings;\n}\n\nexport interface TreeEffectsOptions {\n /** Which effects: a Style name (its suggested combination), custom settings, or `null` (none). Default: none. */\n effects?: TreeEffectsChoice;\n /**\n * The trees to outline (Trees, Forests, groups of them; mutable, read on every draw).\n * Default: every tree in the scene.\n */\n selection?: Object3D[];\n}\n\n/**\n * A ready-made post-processing pipeline (`RenderPipeline`) with the Tree Effects: render with\n * `effects.render()` instead of `renderer.render(scene, camera)`. Switch the combination with\n * `effects.set('stylized')` (e.g. a preview). For your own pipeline, use {@link treeEffectsPass}\n * and {@link applyTreeEffects} instead.\n */\nexport class TreeEffects {\n readonly pipeline: RenderPipeline;\n /** The scene pass (colour + tree mask). */\n readonly scenePass: TreeEffectsPass;\n private nodes: Node[] = [];\n private current: TreeEffectsSettings = {};\n\n constructor(renderer: Renderer, scene: Scene, camera: Camera, options: TreeEffectsOptions = {}) {\n this.pipeline = new RenderPipeline(renderer);\n this.scenePass = treeEffectsPass(scene, camera, options.selection ?? null);\n this.set(options.effects ?? null);\n }\n\n /** The active combination (`{}` = none). */\n get settings(): TreeEffectsSettings {\n return this.current;\n }\n\n /** Switches to a Style's suggested combination, custom settings, or none (`null`). */\n set(effects: TreeEffectsChoice): void {\n this.current = resolveEffects(effects);\n this.disposeNodes();\n const output = applyTreeEffects(this.scenePass, this.current);\n this.nodes = collectEffectNodes(output, this.scenePass.color);\n this.pipeline.outputNode = output;\n this.pipeline.needsUpdate = true;\n }\n\n /** Renders the scene with the effects (call instead of `renderer.render(scene, camera)`). */\n render(): void {\n this.pipeline.render();\n }\n\n dispose(): void {\n this.disposeNodes();\n this.scenePass.pass.dispose();\n this.pipeline.dispose();\n }\n\n private disposeNodes(): void {\n for (const node of this.nodes) node.dispose();\n this.nodes = [];\n }\n}\n\n/** The render-target owning nodes (blur) in an effects graph, to dispose them on change. */\nfunction collectEffectNodes(output: Node, stop: Node): Node[] {\n const found = new Set<Node>();\n const visit = (node: Node, seen: Set<Node>): void => {\n if (seen.has(node) || node === stop) return;\n seen.add(node);\n const n = node as Node & { isGaussianBlurNode?: boolean };\n if (n.isGaussianBlurNode) found.add(node);\n for (const child of node.getChildren()) visit(child as Node, seen);\n };\n visit(output, new Set());\n return [...found];\n}\n\n/** Shorthand for `new TreeEffects(renderer, scene, camera, options)`. */\nexport function createTreeEffects(renderer: Renderer, scene: Scene, camera: Camera, options?: TreeEffectsOptions): TreeEffects {\n return new TreeEffects(renderer, scene, camera, options);\n}\n"],"mappings":";;;;;AAeA,IAAa,YAAY;;;;;AASzB,SAAgB,WAAW,UAAwD;CACjF,MAAM,OAAgB,UAAU,SAAS;CACzC,OAAO,SAAS,UAAU,SAAS,WAAW,OAAO;AACvD;AAEA,SAAS,WAAW,QAAyB,WAAyC;CACpF,KAAK,IAAI,IAAI,QAAQ,GAAG,IAAI,EAAE,QAAQ,IAAI,UAAU,SAAS,CAAC,GAAG,OAAO;CACxE,OAAO;AACT;;;;;;;;;;AAWA,SAAgB,eAAe,YAAwC,MAAoB;CACzF,OAAO,QAAQ,IAAI,QAAQ,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,gBAAgB,OAAO,SAAS;EACtE,MAAM,OAAO,WAAW,MAAM,QAAQ;EACtC,MAAM,WAAW,SAAS,SAAS,cAAc,QAAQ,WAAW,MAAM,QAAQ,SAAS;EAC3F,KAAK,MAAM,IAAI,OAAO,IAAI,GAAG,SAAS,WAAW,IAAI,GAAG,WAAW,IAAI,GAAG,CAAC;CAE7E,CAAC;AACH;;;;;;AAOA,SAAgB,YAAY,YAAwC,MAAe;CACjF,MAAM,OAAO,IAAI,GAAG,YAAY,eAAe,SAAS,EAAE,CAAC;CAC3D,KAAK,cAAc,WAAW,GAAU,CAAC;CACzC,OAAO;AACT;;;;;;AAoBA,SAAgB,gBAAgB,OAAc,QAAgB,YAAwC,MAA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,WAAW,IAAI;CAClC;;CAGA,IAAI,WAAgC;EAClC,OAAO,KAAK;CACd;;CAGA,IAAI,SAAkC;EACpC,KAAK,UAAU,eAAe,OAAO;EACrC,KAAK,aAAa;EAClB,MAAM,SAAS,iBAAiB,KAAK,WAAW,KAAK,OAAO;EAC5D,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,UAAU,KAAK;EAC5D,KAAK,SAAS,aAAa;EAC3B,KAAK,SAAS,cAAc;CAC9B;;CAGA,SAAe;EACb,KAAK,SAAS,OAAO;CACvB;CAEA,UAAgB;EACd,KAAK,aAAa;EAClB,KAAK,UAAU,KAAK,QAAQ;EAC5B,KAAK,SAAS,QAAQ;CACxB;CAEA,eAA6B;EAC3B,KAAK,MAAM,QAAQ,KAAK,OAAO,KAAK,QAAQ;EAC5C,KAAK,QAAQ,CAAC;CAChB;AACF;;AAGA,SAAS,mBAAmB,QAAc,MAAoB;CAC5D,MAAM,wBAAQ,IAAI,IAAU;CAC5B,MAAM,SAAS,MAAY,SAA0B;EACnD,IAAI,KAAK,IAAI,IAAI,KAAK,SAAS,MAAM;EACrC,KAAK,IAAI,IAAI;EAEb,IAAIC,KAAE,oBAAoB,MAAM,IAAI,IAAI;EACxC,KAAK,MAAM,SAAS,KAAK,YAAY,GAAG,MAAM,OAAe,IAAI;CACnE;CACA,MAAM,wBAAQ,IAAI,IAAI,CAAC;CACvB,OAAO,CAAC,GAAG,KAAK;AAClB;;AAGA,SAAgB,kBAAkB,UAAoB,OAAc,QAAgB,SAA2C;CAC7H,OAAO,IAAI,YAAY,UAAU,OAAO,QAAQ,OAAO;AACzD"}
|
|
1
|
+
{"version":3,"file":"effects.js","names":["tslColor","color","tslColor","color","tslColor","n"],"sources":["../src/effects/mask.ts","../src/effects/outline.ts","../src/effects/glow.ts","../src/effects/grade.ts","../src/effects/suggested.ts","../src/effects/effects.ts"],"sourcesContent":["import {\n UnsignedByteType,\n Vector4,\n type Camera,\n type Material,\n type MRTNode,\n type Node,\n type Object3D,\n type PassNode,\n type Scene,\n type TextureNode,\n} from 'three/webgpu';\nimport { mrt, output, pass, uniform } from 'three/tsl';\n\n/** Name of the tree mask output in a pass's MRT (`scenePass.getTextureNode(TREE_MASK)`). */\nexport const TREE_MASK = 'treeMask';\n\n/** The part of a tree a material draws. */\nexport type TreePart = 'bark' | 'leaves' | 'fruit';\n\n/**\n * Which tree part a material draws: 'bark', 'leaves' or 'fruit' for tree.js materials (and their clones),\n * `null` for anything else. Tree Effects only change the pixels drawn by these materials.\n */\nexport function treePartOf(material: Material | null | undefined): TreePart | null {\n const part: unknown = material?.userData.treePart;\n return part === 'bark' || part === 'leaves' || part === 'fruit' ? part : null;\n}\n\nfunction isSelected(object: Object3D | null, selection: readonly Object3D[]): boolean {\n for (let o = object; o; o = o.parent) if (selection.includes(o)) return true;\n return false;\n}\n\n/**\n * TSL node: the tree mask value of the object being drawn, `vec4(tree, leaves, selected, 1)`:\n * r = 1 on tree pixels (bark, leaves and Fruit), g = 1 on leaf pixels, b = 1 on pixels of selected trees (the outline's\n * selection), 0 elsewhere. A per-object uniform decided from the drawn material\n * ({@link treePartOf}), so no tree material is changed and every other object writes 0.\n *\n * `selection`: the selected tree objects (Trees, Forests, any ancestor of tree meshes), read on\n * every draw, so it may be changed in place. `null` (default) selects every tree.\n */\nexport function createTreeMask(selection: readonly Object3D[] | null = null): Node<'vec4'> {\n return uniform(new Vector4(0, 0, 0, 1)).onObjectUpdate((frame, self) => {\n const part = treePartOf(frame.material);\n const selected = part !== null && (selection === null || isSelected(frame.object, selection));\n self.value.set(part ? 1 : 0, part === 'leaves' ? 1 : 0, selected ? 1 : 0, 1);\n return undefined;\n });\n}\n\n/**\n * The MRT output that renders the tree mask ({@link createTreeMask}) next to the colour. Merge it\n * into the MRT of your own scene pass: `scenePass.setMRT(mrt({ output, normal: normalView }).merge(treeMaskMRT()))`,\n * then read it with `scenePass.getTextureNode(TREE_MASK)`.\n */\nexport function treeMaskMRT(selection: readonly Object3D[] | null = null): MRTNode {\n const node = mrt({ [TREE_MASK]: createTreeMask(selection) });\n node.setClearColor(TREE_MASK, 0x000000, 0);\n return node;\n}\n\n/** What every Tree Effect reads: the scene colour and the tree mask (screen-space nodes). */\nexport interface TreeEffectInput {\n /** Scene colour (linear, before tone mapping), e.g. `scenePass.getTextureNode('output')`. */\n color: Node<'vec4'>;\n /** Tree mask texture (see {@link createTreeMask}), e.g. `scenePass.getTextureNode(TREE_MASK)`. */\n mask: TextureNode;\n}\n\n/** A scene pass that renders the colour and the tree mask, ready for the Tree Effects. */\nexport interface TreeEffectsPass extends TreeEffectInput {\n pass: PassNode;\n}\n\n/**\n * Creates `pass(scene, camera)` with MRT `{ output, treeMask }` and returns it with its colour and\n * mask texture nodes. `selection`: the trees to outline (default `null` = all trees), see\n * {@link createTreeMask}. If your pipeline already has a scene pass, merge {@link treeMaskMRT} into it instead.\n */\nexport function treeEffectsPass(scene: Scene, camera: Camera, selection: readonly Object3D[] | null = null): TreeEffectsPass {\n const scenePass = pass(scene, camera);\n scenePass.setMRT(mrt({ output }).merge(treeMaskMRT(selection)));\n scenePass.getTexture(TREE_MASK).type = UnsignedByteType;\n return { pass: scenePass, color: scenePass.getTextureNode('output'), mask: scenePass.getTextureNode(TREE_MASK) };\n}\n","import { Color, type ColorRepresentation, type Node } from 'three/webgpu';\nimport { color as tslColor, float, mix, textureSize, uv, vec2, vec4 } from 'three/tsl';\nimport type { TreeEffectInput } from './mask';\n\n/** Tree outline settings. */\nexport interface TreeOutlineOptions {\n /** Line colour (default a dark green-brown). */\n color?: ColorRepresentation;\n /** Line width in pixels (default 2). */\n thickness?: number;\n /** Opacity of the line, 0..1 (default 1). */\n strength?: number;\n}\n\n// Eight sample directions around a pixel (unit length).\nconst D = Math.SQRT1_2;\nconst DIRECTIONS: [number, number][] = [[1, 0], [-1, 0], [0, 1], [0, -1], [D, D], [D, -D], [-D, D], [-D, -D]];\n\n/**\n * Tree Effect: an outline along the silhouettes of the selected trees (the `selection` of the\n * tree mask, see `createTreeMask`; all trees by default), around the outside of the canopy and\n * the gaps in it. The line is drawn on the inside of the silhouette, so only tree pixels change.\n */\nexport function treeOutline(input: TreeEffectInput, options: TreeOutlineOptions = {}): Node<'vec4'> {\n const { color = '#1d2a14', thickness = 2, strength = 1 } = options;\n const { mask } = input;\n const step = vec2(thickness).div(vec2(textureSize(mask) as unknown as Node<'ivec2'>));\n const centre = uv();\n // Fraction of neighbours (at `thickness` px) that are not selected tree pixels.\n let outside: Node<'float'> = float(0);\n for (const [x, y] of DIRECTIONS) {\n outside = outside.add(float(1).sub(mask.sample(centre.add(step.mul(vec2(x, y)))).b));\n }\n const edge = outside.mul(3 / DIRECTIONS.length).clamp(0, 1).mul(mask.sample(centre).b).mul(strength);\n return vec4(mix(input.color.rgb, tslColor(new Color(color)), edge), input.color.a);\n}\n","import { Color, type ColorRepresentation, type Node } from 'three/webgpu';\nimport { color as tslColor, luminance, smoothstep, vec4 } from 'three/tsl';\nimport { gaussianBlur } from 'three/addons/tsl/display/GaussianBlurNode.js';\nimport type { TreeEffectInput } from './mask';\n\n/** Leaf glow settings. */\nexport interface LeafGlowOptions {\n /** Glow colour, multiplied with the blurred leaf colour (default white). */\n color?: ColorRepresentation;\n /** Glow strength (default 0.6). */\n intensity?: number;\n /** Only leaf pixels brighter than this (linear luminance) glow; 0 = all leaves (default 0.15). */\n threshold?: number;\n /** Blur radius (Gaussian sigma, in pixels at half resolution; default 6). */\n radius?: number;\n}\n\n/**\n * Tree Effect: a soft glow of the leaves. The bright (sunlit) leaf pixels are blurred and added\n * back onto the tree pixels (leaves and the wood between them), never onto the rest of the scene.\n */\nexport function leafGlow(input: TreeEffectInput, options: LeafGlowOptions = {}): Node<'vec4'> {\n const { color = '#ffffff', intensity = 0.6, threshold = 0.15, radius = 6 } = options;\n const bright = smoothstep(threshold, threshold * 2 + 0.05, luminance(input.color.rgb));\n const leaves = vec4(input.color.rgb.mul(input.mask.g).mul(bright), 1);\n const blurred = gaussianBlur(leaves, null, radius, { resolutionScale: 0.5 });\n const glow = blurred.rgb.mul(tslColor(new Color(color))).mul(intensity).mul(input.mask.r);\n return vec4(input.color.rgb.add(glow), input.color.a);\n}\n","import { Color, type ColorRepresentation, type Node } from 'three/webgpu';\nimport { color as tslColor, float, luminance, mix, select, vec3, vec4 } from 'three/tsl';\nimport type { TreeEffectInput } from './mask';\n\n/** Tree colour grading settings (all optional; the defaults change nothing). */\nexport interface TreeColorGradeOptions {\n /** Brightness multiplier (default 1). */\n exposure?: number;\n /** 0 = grey, 1 = unchanged (default), > 1 = more saturated. */\n saturation?: number;\n /** Contrast around mid grey: 1 = unchanged (default), > 1 = more contrast. */\n contrast?: number;\n /** Colour multiplied in, e.g. a warm '#fff2dd' (default white). */\n tint?: ColorRepresentation;\n}\n\nconst MID_GREY = 0.18; // linear\n\n/**\n * Tree Effect: colour grading (exposure, tint, saturation, contrast) of the tree pixels only.\n * Returns the graded colour where the tree mask is set and `input.color` unchanged elsewhere.\n */\nexport function treeColorGrade(input: TreeEffectInput, options: TreeColorGradeOptions = {}): Node<'vec4'> {\n const { exposure = 1, saturation = 1, contrast = 1, tint = '#ffffff' } = options;\n const tinted = input.color.rgb.mul(tslColor(new Color(tint))).mul(exposure);\n const saturated = mix(vec3(luminance(tinted)), tinted, saturation).max(0);\n const contrasted = saturated.div(MID_GREY).pow(vec3(float(contrast))).mul(MID_GREY);\n return select(input.mask.r.greaterThan(0.5), vec4(contrasted, input.color.a), input.color);\n}\n","import type { StyleName } from '../styles/registry';\nimport type { TreeColorGradeOptions } from './grade';\nimport type { LeafGlowOptions } from './glow';\nimport type { TreeOutlineOptions } from './outline';\n\n/** A combination of Tree Effects; leave an effect out to skip it. `{}` = no effects. */\nexport interface TreeEffectsSettings {\n grade?: TreeColorGradeOptions;\n glow?: LeafGlowOptions;\n outline?: TreeOutlineOptions;\n}\n\n/** The suggested combination of Tree Effects for each built-in Style. */\nexport const SUGGESTED_TREE_EFFECTS: Record<StyleName, TreeEffectsSettings> = {\n // Crisp facets: a dark ink line and slightly punchier colours.\n 'low-poly': {\n grade: { saturation: 1.15, contrast: 1.1 },\n outline: { color: '#18230f', thickness: 2, strength: 0.9 },\n },\n // Storybook look: soft glowing foliage, a warm tint and a soft coloured outline.\n stylized: {\n grade: { saturation: 0.95, contrast: 1.08, tint: '#fff1e0' },\n glow: { color: '#fff6c8', intensity: 0.45, threshold: 0.3, radius: 8 },\n outline: { color: '#2b3a1c', thickness: 2, strength: 0.6 },\n },\n // Natural: only a gentle grade (warmer, a touch more contrast) and a faint sunlit leaf glow.\n realistic: {\n grade: { exposure: 1.05, contrast: 1.08, saturation: 0.95, tint: '#fff5e6' },\n glow: { color: '#e8ffc0', intensity: 0.35, threshold: 0.12, radius: 4 },\n },\n};\n","import { RenderPipeline, type Camera, type Node, type Object3D, type Renderer, type Scene } from 'three/webgpu';\nimport type { StyleName } from '../styles/registry';\nimport { leafGlow } from './glow';\nimport { treeColorGrade } from './grade';\nimport { treeEffectsPass, type TreeEffectInput, type TreeEffectsPass } from './mask';\nimport { treeOutline } from './outline';\nimport { SUGGESTED_TREE_EFFECTS, type TreeEffectsSettings } from './suggested';\n\n/**\n * Applies a combination of Tree Effects to `input` and returns the resulting colour node, for use in\n * your own post-processing pipeline (`pipeline.outputNode = applyTreeEffects(...)`, or feed it into\n * more effects). Order: colour grade, leaf glow, outline. Empty settings return `input.color`.\n */\nexport function applyTreeEffects(input: TreeEffectInput, settings: TreeEffectsSettings): Node<'vec4'> {\n let color = input.color;\n if (settings.grade) color = treeColorGrade({ color, mask: input.mask }, settings.grade);\n if (settings.glow) color = leafGlow({ color, mask: input.mask }, settings.glow);\n if (settings.outline) color = treeOutline({ color, mask: input.mask }, settings.outline);\n return color;\n}\n\n/** The suggested combination of a built-in Style, or the settings themselves; `null` = no effects. */\nexport type TreeEffectsChoice = StyleName | TreeEffectsSettings | null;\n\nfunction resolveEffects(choice: TreeEffectsChoice): TreeEffectsSettings {\n if (choice === null) return {};\n if (typeof choice !== 'string') return choice;\n const settings = (SUGGESTED_TREE_EFFECTS as Record<string, TreeEffectsSettings | undefined>)[choice];\n if (!settings) throw new Error(`No suggested Tree Effects for Style \"${choice}\"`);\n return settings;\n}\n\nexport interface TreeEffectsOptions {\n /** Which effects: a Style name (its suggested combination), custom settings, or `null` (none). Default: none. */\n effects?: TreeEffectsChoice;\n /**\n * The trees to outline (Trees, Forests, groups of them; mutable, read on every draw).\n * Default: every tree in the scene.\n */\n selection?: Object3D[];\n}\n\n/**\n * A ready-made post-processing pipeline (`RenderPipeline`) with the Tree Effects: render with\n * `effects.render()` instead of `renderer.render(scene, camera)`. Switch the combination with\n * `effects.set('stylized')` (e.g. a preview). For your own pipeline, use {@link treeEffectsPass}\n * and {@link applyTreeEffects} instead.\n */\nexport class TreeEffects {\n readonly pipeline: RenderPipeline;\n /** The scene pass (colour + tree mask). */\n readonly scenePass: TreeEffectsPass;\n private nodes: Node[] = [];\n private current: TreeEffectsSettings = {};\n\n constructor(renderer: Renderer, scene: Scene, camera: Camera, options: TreeEffectsOptions = {}) {\n this.pipeline = new RenderPipeline(renderer);\n this.scenePass = treeEffectsPass(scene, camera, options.selection ?? null);\n this.set(options.effects ?? null);\n }\n\n /** The active combination (`{}` = none). */\n get settings(): TreeEffectsSettings {\n return this.current;\n }\n\n /** Switches to a Style's suggested combination, custom settings, or none (`null`). */\n set(effects: TreeEffectsChoice): void {\n this.current = resolveEffects(effects);\n this.disposeNodes();\n const output = applyTreeEffects(this.scenePass, this.current);\n this.nodes = collectEffectNodes(output, this.scenePass.color);\n this.pipeline.outputNode = output;\n this.pipeline.needsUpdate = true;\n }\n\n /** Renders the scene with the effects (call instead of `renderer.render(scene, camera)`). */\n render(): void {\n this.pipeline.render();\n }\n\n dispose(): void {\n this.disposeNodes();\n this.scenePass.pass.dispose();\n this.pipeline.dispose();\n }\n\n private disposeNodes(): void {\n for (const node of this.nodes) node.dispose();\n this.nodes = [];\n }\n}\n\n/** The render-target owning nodes (blur) in an effects graph, to dispose them on change. */\nfunction collectEffectNodes(output: Node, stop: Node): Node[] {\n const found = new Set<Node>();\n const visit = (node: Node, seen: Set<Node>): void => {\n if (seen.has(node) || node === stop) return;\n seen.add(node);\n const n = node as Node & { isGaussianBlurNode?: boolean };\n if (n.isGaussianBlurNode) found.add(node);\n for (const child of node.getChildren()) visit(child as Node, seen);\n };\n visit(output, new Set());\n return [...found];\n}\n\n/** Shorthand for `new TreeEffects(renderer, scene, camera, options)`. */\nexport function createTreeEffects(renderer: Renderer, scene: Scene, camera: Camera, options?: TreeEffectsOptions): TreeEffects {\n return new TreeEffects(renderer, scene, camera, options);\n}\n"],"mappings":";;;;;AAeA,IAAa,YAAY;;;;;AASzB,SAAgB,WAAW,UAAwD;CACjF,MAAM,OAAgB,UAAU,SAAS;CACzC,OAAO,SAAS,UAAU,SAAS,YAAY,SAAS,UAAU,OAAO;AAC3E;AAEA,SAAS,WAAW,QAAyB,WAAyC;CACpF,KAAK,IAAI,IAAI,QAAQ,GAAG,IAAI,EAAE,QAAQ,IAAI,UAAU,SAAS,CAAC,GAAG,OAAO;CACxE,OAAO;AACT;;;;;;;;;;AAWA,SAAgB,eAAe,YAAwC,MAAoB;CACzF,OAAO,QAAQ,IAAI,QAAQ,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,gBAAgB,OAAO,SAAS;EACtE,MAAM,OAAO,WAAW,MAAM,QAAQ;EACtC,MAAM,WAAW,SAAS,SAAS,cAAc,QAAQ,WAAW,MAAM,QAAQ,SAAS;EAC3F,KAAK,MAAM,IAAI,OAAO,IAAI,GAAG,SAAS,WAAW,IAAI,GAAG,WAAW,IAAI,GAAG,CAAC;CAE7E,CAAC;AACH;;;;;;AAOA,SAAgB,YAAY,YAAwC,MAAe;CACjF,MAAM,OAAO,IAAI,GAAG,YAAY,eAAe,SAAS,EAAE,CAAC;CAC3D,KAAK,cAAc,WAAW,GAAU,CAAC;CACzC,OAAO;AACT;;;;;;AAoBA,SAAgB,gBAAgB,OAAc,QAAgB,YAAwC,M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AQ,WAAW,IAAI;CAClC;;CAGA,IAAI,WAAgC;EAClC,OAAO,KAAK;CACd;;CAGA,IAAI,SAAkC;EACpC,KAAK,UAAU,eAAe,OAAO;EACrC,KAAK,aAAa;EAClB,MAAM,SAAS,iBAAiB,KAAK,WAAW,KAAK,OAAO;EAC5D,KAAK,QAAQ,mBAAmB,QAAQ,KAAK,UAAU,KAAK;EAC5D,KAAK,SAAS,aAAa;EAC3B,KAAK,SAAS,cAAc;CAC9B;;CAGA,SAAe;EACb,KAAK,SAAS,OAAO;CACvB;CAEA,UAAgB;EACd,KAAK,aAAa;EAClB,KAAK,UAAU,KAAK,QAAQ;EAC5B,KAAK,SAAS,QAAQ;CACxB;CAEA,eAA6B;EAC3B,KAAK,MAAM,QAAQ,KAAK,OAAO,KAAK,QAAQ;EAC5C,KAAK,QAAQ,CAAC;CAChB;AACF;;AAGA,SAAS,mBAAmB,QAAc,MAAoB;CAC5D,MAAM,wBAAQ,IAAI,IAAU;CAC5B,MAAM,SAAS,MAAY,SAA0B;EACnD,IAAI,KAAK,IAAI,IAAI,KAAK,SAAS,MAAM;EACrC,KAAK,IAAI,IAAI;EAEb,IAAIC,KAAE,oBAAoB,MAAM,IAAI,IAAI;EACxC,KAAK,MAAM,SAAS,KAAK,YAAY,GAAG,MAAM,OAAe,IAAI;CACnE;CACA,MAAM,wBAAQ,IAAI,IAAI,CAAC;CACvB,OAAO,CAAC,GAAG,KAAK;AAClB;;AAGA,SAAgB,kBAAkB,UAAoB,OAAc,QAAgB,SAA2C;CAC7H,OAAO,IAAI,YAAY,UAAU,OAAO,QAAQ,OAAO;AACzD"}
|
package/dist/forest/Forest.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BufferGeometry, Group, InstancedMesh, type MeshStandardNodeMaterial } 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 TextureOptions } from '../textures';
|
|
5
5
|
import { Wind, WindResponse, type WindSource } from '../wind';
|
|
@@ -57,7 +57,8 @@ export declare class ForestTree implements ForestTreeTraits {
|
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
59
|
* One Variant of a Forest: one Seed's tree, drawn once per tree that uses it with an instanced
|
|
60
|
-
* wood mesh
|
|
60
|
+
* wood mesh, an instanced leaf mesh and, when the Definition has Fruit, an instanced fruit mesh
|
|
61
|
+
* (one draw call per material). All three share one instance matrix buffer.
|
|
61
62
|
*/
|
|
62
63
|
export declare class ForestVariant {
|
|
63
64
|
private readonly forest;
|
|
@@ -68,18 +69,26 @@ export declare class ForestVariant {
|
|
|
68
69
|
readonly windResponse: WindResponse;
|
|
69
70
|
readonly barkMaterial: MeshStandardNodeMaterial;
|
|
70
71
|
readonly leafMaterial: MeshStandardNodeMaterial;
|
|
72
|
+
/** Fruit material, null when the Definition has no Fruit. */
|
|
73
|
+
readonly fruitMaterial: MeshStandardNodeMaterial | null;
|
|
71
74
|
/** The trees drawn as this Variant, in instance order. */
|
|
72
75
|
readonly trees: ForestTree[];
|
|
73
76
|
private woodMesh;
|
|
74
77
|
private leafMesh;
|
|
78
|
+
private fruitMesh;
|
|
75
79
|
private instanceData;
|
|
76
80
|
private readonly woodSource;
|
|
77
81
|
private readonly leafSource;
|
|
82
|
+
private readonly fruitSource;
|
|
78
83
|
constructor(forest: Forest, definition: TreeDefinition, index: number, seed: number, wind: WindSource, capacity: number, textures?: TextureOptions);
|
|
79
84
|
/** Instanced mesh of trunks and branches. Replaced (not resized) when the Variant outgrows its capacity. */
|
|
80
85
|
get wood(): InstancedMesh<BufferGeometry, MeshStandardNodeMaterial>;
|
|
81
86
|
/** Instanced mesh of the leaves. Replaced along with {@link wood}. */
|
|
82
87
|
get leaves(): InstancedMesh<BufferGeometry, MeshStandardNodeMaterial>;
|
|
88
|
+
/** Instanced mesh of the Fruit (null when the Definition has no Fruit). Replaced along with {@link wood}. */
|
|
89
|
+
get fruit(): InstancedMesh<BufferGeometry, MeshStandardNodeMaterial> | null;
|
|
90
|
+
/** The Variant's meshes: wood, leaves and (with Fruit) fruit. */
|
|
91
|
+
get meshes(): InstancedMesh<BufferGeometry, MeshStandardNodeMaterial>[];
|
|
83
92
|
get capacity(): number;
|
|
84
93
|
/** @internal */
|
|
85
94
|
add(tree: ForestTree): void;
|
|
@@ -117,6 +126,7 @@ export declare class Forest extends Group {
|
|
|
117
126
|
private readonly windBinding;
|
|
118
127
|
private growthValue;
|
|
119
128
|
private seasonValue;
|
|
129
|
+
private readonly features;
|
|
120
130
|
constructor(definition: TreeDefinition, placements?: readonly ForestPlacement[], options?: ForestOptions);
|
|
121
131
|
/**
|
|
122
132
|
* The Wind every tree of this forest sways with. Assigning another Wind only rebinds uniforms:
|
|
@@ -150,6 +160,31 @@ export declare class Forest extends Group {
|
|
|
150
160
|
/** Season of the whole forest: setting it sets every tree's Season (and that of trees planted later). */
|
|
151
161
|
get season(): number;
|
|
152
162
|
set season(value: number);
|
|
163
|
+
/**
|
|
164
|
+
* Crown Normals amount (0..1), from the Definition's `materials.leaf.crownNormals`; null when it is off.
|
|
165
|
+
* Setting it (clamped to 0..1) only writes a uniform: no regeneration, no recompile. Throws on a
|
|
166
|
+
* forest without Crown Normals (switching the feature on needs a new forest).
|
|
167
|
+
*/
|
|
168
|
+
get crownNormals(): number | null;
|
|
169
|
+
set crownNormals(value: number);
|
|
170
|
+
/**
|
|
171
|
+
* Leaf Translucency settings (a copy), from the Definition's `materials.leaf.translucency`; null when it
|
|
172
|
+
* is off. Setting any of them (each clamped to 0..1, the others kept) only writes uniforms: no
|
|
173
|
+
* regeneration, no recompile. Throws on a forest without Leaf Translucency.
|
|
174
|
+
*/
|
|
175
|
+
get translucency(): TranslucencyDefinition | null;
|
|
176
|
+
set translucency(value: Partial<TranslucencyDefinition>);
|
|
177
|
+
/**
|
|
178
|
+
* The Material Features this forest shows, with their current (possibly live-tuned) values: the
|
|
179
|
+
* Definition's (see `materialFeaturesOf`), except that Crown Normals at 0 count as off.
|
|
180
|
+
*/
|
|
181
|
+
get materialFeatures(): MaterialFeatures;
|
|
182
|
+
/**
|
|
183
|
+
* Structural Occlusion strength (0..1) of every tree, from the Definition's `materials.occlusion`; null
|
|
184
|
+
* when it has none. Setting it (clamped to 0..1) only writes a uniform. Throws without Structural Occlusion.
|
|
185
|
+
*/
|
|
186
|
+
get occlusionStrength(): number | null;
|
|
187
|
+
set occlusionStrength(value: number);
|
|
153
188
|
/** Frees every Variant's geometries, materials and instance buffers, and removes the forest from its parent. */
|
|
154
189
|
dispose(): void;
|
|
155
190
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Forest.d.ts","sourceRoot":"","sources":["../../src/forest/Forest.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EAGd,KAAK,EAGL,aAAa,EAMb,KAAK,wBAAwB,EAC9B,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"Forest.d.ts","sourceRoot":"","sources":["../../src/forest/Forest.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EAGd,KAAK,EAGL,aAAa,EAMb,KAAK,wBAAwB,EAC9B,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC9F,OAAO,EAAmD,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAO9F,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAa,IAAI,EAAe,YAAY,EAAE,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AAEtF,OAAO,EAOL,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACtB,MAAM,aAAa,CAAC;AAErB,uCAAuC;AACvC,MAAM,WAAW,aAAa;IAC5B,iGAAiG;IACjG,QAAQ,CAAC,EAAE,MAAM,CA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AE,MAAM,EAElC;IAED,gHAAgH;IACvG,OAAO,IAAI,IAAI;CAMzB"}
|
package/dist/forest/nodes.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ export declare function instanceState(): {
|
|
|
17
17
|
season: Node<'float'>;
|
|
18
18
|
windPhase: Node<'float'>;
|
|
19
19
|
};
|
|
20
|
+
/** Rotates `v` by the instance quaternion (`inverse` = by its conjugate): tree space to forest space. */
|
|
21
|
+
export declare function instanceRotate(v: Node<'vec3'>, inverse?: boolean): Node<'vec3'>;
|
|
20
22
|
/**
|
|
21
23
|
* The vertex position of a Forest tree (positionNode of an instanced Variant mesh).
|
|
22
24
|
*
|
|
@@ -26,6 +28,9 @@ export declare function instanceState(): {
|
|
|
26
28
|
* `positionGeometry`, and only their displacement is turned into forest space with the
|
|
27
29
|
* instance rotation and scale: M·(p + d) = M·p + R·s·d. The Wind direction goes the other way
|
|
28
30
|
* (forest -> tree space) and each tree sways with its own phase.
|
|
31
|
+
*
|
|
32
|
+
* `base`: the tree-space position Growth starts from (default `positionGeometry`); Fruit passes
|
|
33
|
+
* its Season-scaled position here.
|
|
29
34
|
*/
|
|
30
|
-
export declare function forestPosition(wind: WindSource, response: WindResponse): Node<'vec3'>;
|
|
35
|
+
export declare function forestPosition(wind: WindSource, response: WindResponse, base?: Node<'vec3'>): Node<'vec3'>;
|
|
31
36
|
//# sourceMappingURL=nodes.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../src/forest/nodes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGzC,OAAO,EAAmC,KAAK,YAAY,EAAE,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AAE9F;;;;GAIG;AACH,eAAO,MAAM,eAAe,IAAI,CAAC;AACjC,eAAO,MAAM,mBAAmB;;;CAAuC,CAAC;AAExE,iEAAiE;AACjE,wBAAgB,aAAa,IAAI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