@casmo/tree.js 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +206 -0
- package/dist/{apply-CcodnAbs.js → apply-Cio2t7CZ.js} +51 -16
- package/dist/apply-Cio2t7CZ.js.map +1 -0
- package/dist/bake/index.d.ts +43 -4
- package/dist/bake/index.d.ts.map +1 -1
- package/dist/definition/defaults.d.ts +9 -1
- package/dist/definition/defaults.d.ts.map +1 -1
- package/dist/definition/index.d.ts +2 -2
- package/dist/definition/index.d.ts.map +1 -1
- package/dist/definition/schema.d.ts.map +1 -1
- package/dist/definition/types.d.ts +86 -0
- package/dist/definition/types.d.ts.map +1 -1
- package/dist/forest/Forest.d.ts +27 -1
- package/dist/forest/Forest.d.ts.map +1 -1
- package/dist/forest/nodes.d.ts +2 -0
- package/dist/forest/nodes.d.ts.map +1 -1
- package/dist/{forest-DTrD8puH.js → forest-ChEaWJrf.js} +1121 -191
- package/dist/forest-ChEaWJrf.js.map +1 -0
- package/dist/generator/crown.d.ts +28 -0
- package/dist/generator/crown.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 +2 -1
- package/dist/generator/index.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 +8 -0
- package/dist/generator/trunk.d.ts.map +1 -1
- package/dist/generator/types.d.ts +27 -1
- 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 +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +234 -28
- 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 +7 -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-C6-wuJ29.js → names-BE9he6CS.js} +133 -9
- package/dist/names-BE9he6CS.js.map +1 -0
- package/dist/react.js +1 -1
- package/dist/species/almond.js +12 -2
- package/dist/species/almond.json +10 -1
- package/dist/species/apple.js +12 -2
- package/dist/species/apple.json +10 -1
- package/dist/species/ash.js +12 -2
- package/dist/species/ash.json +10 -1
- package/dist/species/beech.js +12 -2
- package/dist/species/beech.json +10 -1
- package/dist/species/birch.js +12 -2
- package/dist/species/birch.json +10 -1
- package/dist/species/cedar.js +12 -2
- package/dist/species/cedar.json +10 -1
- package/dist/species/cherry.js +12 -2
- package/dist/species/cherry.json +10 -1
- package/dist/species/chestnut.js +12 -2
- package/dist/species/chestnut.json +10 -1
- package/dist/species/douglas-fir.js +12 -2
- package/dist/species/douglas-fir.json +10 -1
- package/dist/species/elm.js +12 -2
- package/dist/species/elm.json +10 -1
- package/dist/species/hemlock.js +12 -2
- package/dist/species/hemlock.json +10 -1
- package/dist/species/hickory.js +12 -2
- package/dist/species/hickory.json +10 -1
- package/dist/species/juniper.js +12 -2
- package/dist/species/juniper.json +10 -1
- package/dist/species/mahogany.js +12 -2
- package/dist/species/mahogany.json +10 -1
- package/dist/species/maple.js +12 -2
- package/dist/species/maple.json +10 -1
- package/dist/species/oak.js +12 -2
- package/dist/species/oak.json +10 -1
- package/dist/species/olive.js +12 -2
- package/dist/species/olive.json +10 -1
- package/dist/species/peach.js +12 -2
- package/dist/species/peach.json +10 -1
- package/dist/species/pear.js +12 -2
- package/dist/species/pear.json +10 -1
- package/dist/species/pine.js +12 -2
- package/dist/species/pine.json +10 -1
- package/dist/species/plum.js +12 -2
- package/dist/species/plum.json +10 -1
- package/dist/species/red-oak.js +12 -2
- package/dist/species/red-oak.json +10 -1
- package/dist/species/redwood.js +12 -2
- package/dist/species/redwood.json +10 -1
- package/dist/species/sequoia.js +12 -2
- package/dist/species/sequoia.json +10 -1
- package/dist/species/spruce.js +12 -2
- package/dist/species/spruce.json +10 -1
- package/dist/species/teak.js +12 -2
- package/dist/species/teak.json +10 -1
- package/dist/species/types.d.ts +7 -3
- package/dist/species/types.d.ts.map +1 -1
- package/dist/species/walnut.js +12 -2
- package/dist/species/walnut.json +10 -1
- package/dist/species/white-oak.js +12 -2
- package/dist/species/white-oak.json +10 -1
- package/dist/styles/apply.d.ts.map +1 -1
- package/dist/styles/low-poly.js +6 -4
- 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/realistic.js +6 -4
- package/dist/styles/realistic.js.map +1 -1
- package/dist/styles/stylized.js +6 -4
- package/dist/styles/stylized.js.map +1 -1
- package/dist/tree/Tree.d.ts +28 -1
- package/dist/tree/Tree.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/apply-CcodnAbs.js.map +0 -1
- package/dist/forest-DTrD8puH.js.map +0 -1
- package/dist/names-C6-wuJ29.js.map +0 -1
package/README.md
CHANGED
|
@@ -17,10 +17,12 @@ thousands at once as an instanced Forest, add opt-in Tree Effects, or design you
|
|
|
17
17
|
- [Growth and Season](#growth-and-season)
|
|
18
18
|
- [Wind](#wind)
|
|
19
19
|
- [Forests](#forests)
|
|
20
|
+
- [Material Features](#material-features)
|
|
20
21
|
- [Tree Effects](#tree-effects)
|
|
21
22
|
- [React Three Fiber](#react-three-fiber)
|
|
22
23
|
- [Without a bundler: import map (CDN)](#without-a-bundler-import-map-cdn)
|
|
23
24
|
- [Baked Trees (glTF export)](#baked-trees-gltf-export)
|
|
25
|
+
- [Using a Baked Tree in other engines](#using-a-baked-tree-in-other-engines)
|
|
24
26
|
- [Textures](#textures)
|
|
25
27
|
- [Tree Editor](#tree-editor)
|
|
26
28
|
- [Examples](#examples)
|
|
@@ -226,6 +228,83 @@ trunks (each with the whole branch structure) in a small ring, leaning out about
|
|
|
226
228
|
Seed varies each lean). `trunk.gravity` (−1..1) bends only the leader, the top third of each Stem: −1 makes
|
|
227
229
|
it nod like a hemlock's. Absent, a tree has one upright Stem without gravity.
|
|
228
230
|
|
|
231
|
+
A **Root Flare** widens each Stem towards the ground: `trunk.flare` (0..1) eases the bottom ~12% of the
|
|
232
|
+
Stem's length out to (1 + 0.8 × `flare`) × the trunk radius at the base, so the trunk grows into the soil
|
|
233
|
+
instead of standing on it like a post. It is geometry only: branches, leaves, Fruit, Growth, Wind and Sculpts
|
|
234
|
+
stay exactly where they were. The optional `flareSections` (integer ≥ 1) is how many extra rings the flare
|
|
235
|
+
gets, set by `Style.apply` (2 in low-poly, 3 in the others; absent = 3). Absent `flare` means none. Every
|
|
236
|
+
trunk's base ring sits a tenth of its radius below the ground (also without flare), so no seam shows on
|
|
237
|
+
uneven terrain:
|
|
238
|
+
|
|
239
|
+
```ts
|
|
240
|
+
import { createTree, extendDefinition, type TreeDefinitionInput } from '@casmo/tree.js';
|
|
241
|
+
|
|
242
|
+
const oak: TreeDefinitionInput = { schemaVersion: 3, trunk: { length: 5, radius: 0.35, flare: 0.8 } };
|
|
243
|
+
const flared = createTree(oak, { seed: 3 });
|
|
244
|
+
const slender = extendDefinition(oak, { trunk: { flare: 0.15 } }); // a hint of a flare, same crown
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
**Roots** are an optional `roots` block: a few Roots grow from the Root Flare of every Stem, run outward
|
|
248
|
+
and down, taper to a point and vanish below the ground. `count` is Roots per Stem (0..12), `length` a
|
|
249
|
+
fraction of the Stem's length (`lengthVariation` is the Seed's ± range), `radius` a fraction of the trunk's
|
|
250
|
+
base radius, `angle` how steeply they dive (degrees below horizontal, 0..60) and `bend` how much they wander
|
|
251
|
+
sideways. A partial block is filled from `DEFAULT_ROOTS` (5 Roots, length 0.25, radius 0.35, angle 12°);
|
|
252
|
+
absent means none. A single Stem's Roots spread all round it; with several Stems each Stem's Roots cover
|
|
253
|
+
only the half-circle facing away from the others. Roots follow the Sculpts of their Stem: a deleted Stem has
|
|
254
|
+
none, a turned Stem keeps them on the ground at its base, a scaled one scales them with its length, and
|
|
255
|
+
another Stem's Roots never change. The optional `sides` and `sections` are their polygon detail, set by `Style.apply`
|
|
256
|
+
(realistic 8 / 6, stylized 6 / 4, low-poly 3 / 2). Roots are part of the wood mesh, grow with the trunk from
|
|
257
|
+
Growth 0, never sway in the Wind and cannot be Sculpted; adding or removing them leaves the branches,
|
|
258
|
+
leaves and Fruit exactly as they were. The tree data lists them in `skeleton.roots` (`SkeletonRoot` entries
|
|
259
|
+
with paths `0/r0`, `0/r1`, ... and their Stem as `parent`) with their Growth windows in `growth.roots`:
|
|
260
|
+
|
|
261
|
+
```ts
|
|
262
|
+
import { createTree, DEFAULT_ROOTS, type SkeletonRoot } from '@casmo/tree.js';
|
|
263
|
+
|
|
264
|
+
const rooted = createTree({ schemaVersion: 3, trunk: { flare: 0.6 }, roots: { count: 7, angle: 10 } }, { seed: 3 });
|
|
265
|
+
const roots: SkeletonRoot[] = rooted.data.skeleton.roots; // 7 Roots: '0/r0' .. '0/r6', parent '0'
|
|
266
|
+
const tips = roots.map((root) => root.points.at(-1)!.position); // all below the ground (y < 0)
|
|
267
|
+
const windows = rooted.data.growth.roots; // { start: 0, end: 0 }: there from Growth 0, like the trunk
|
|
268
|
+
const defaults = DEFAULT_ROOTS; // { count: 5, length: 0.25, lengthVariation: 0.3, radius: 0.35, angle: 12, bend: 0.3 }
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
A **Ground Tint** darkens the bark or turns it mossy near the soil: the optional
|
|
272
|
+
`materials.bark.groundTint = { color, height, strength }`. At and below the ground the bark colour blends
|
|
273
|
+
towards `color` by `strength` (0..1); the blend fades smoothly to nothing `height` metres (> 0) up the Stem.
|
|
274
|
+
It works in every shading model (standard, flat, toon), is measured on the grown tree (a sapling's tint
|
|
275
|
+
reaches as high, in metres, as a grown tree's) and is baked into the wood's vertex colours of a Baked Tree.
|
|
276
|
+
A partial block is filled from `DEFAULT_GROUND_TINT` (height 0.5 m); absent means none, and no Species sets
|
|
277
|
+
one. It is not part of a Style's look, so `Style.apply` on a Definition keeps it:
|
|
278
|
+
|
|
279
|
+
```ts
|
|
280
|
+
import { createTree, DEFAULT_GROUND_TINT, extendDefinition } from '@casmo/tree.js';
|
|
281
|
+
import realistic from '@casmo/tree.js/styles/realistic';
|
|
282
|
+
import { oak } from '@casmo/tree.js/species';
|
|
283
|
+
|
|
284
|
+
const mossy = extendDefinition(realistic.apply(oak), {
|
|
285
|
+
materials: { bark: { groundTint: { color: '#4d6a26', height: 0.8, strength: 0.7 } } },
|
|
286
|
+
});
|
|
287
|
+
const tree = createTree(mossy, { seed: 3 });
|
|
288
|
+
const wet = extendDefinition(mossy, { materials: { bark: { groundTint: { color: '#1e1610' } } } }); // dark wet bark
|
|
289
|
+
const defaults = DEFAULT_GROUND_TINT; // { color: '#3f4a2a', height: 0.5, strength: 0.6 }
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
The **Crown Volume** is one smooth ellipsoid around all leaves of the fully grown tree (every Stem's
|
|
293
|
+
together), fitted as tightly as an axis-aligned ellipsoid can be. The Generator always computes it,
|
|
294
|
+
deterministically per Definition and Seed, and keeps it next to the geometry as `data.crown = { center, radii }`
|
|
295
|
+
(tree space, metres), so the meshes and `hashTreeData` are unchanged. Use it in your own shaders or
|
|
296
|
+
gameplay: `crownDistance` is 0 at its centre, 1 on its shell and more outside, and `crownNormal` is the
|
|
297
|
+
ellipsoid's outward normal through a point. A tree without leaves gets a Volume around its branches.
|
|
298
|
+
|
|
299
|
+
```ts
|
|
300
|
+
import { createTree, crownDistance, crownNormal, type CrownVolume } from '@casmo/tree.js';
|
|
301
|
+
|
|
302
|
+
const tree = createTree({ schemaVersion: 3 }, { seed: 3 });
|
|
303
|
+
const crown: CrownVolume = tree.data.crown; // { center: [x, y, z], radii: [rx, ry, rz] }
|
|
304
|
+
const inside = crownDistance(crown, [0, 4, 0]) <= 1; // is this point within the crown?
|
|
305
|
+
const outward = crownNormal(crown, [0, 4, 0]); // unit normal of the ellipsoid through the point
|
|
306
|
+
```
|
|
307
|
+
|
|
229
308
|
**Fruit** is an optional `fruit` block: `type` (`'round'`, `'pear'`, `'nut'`, `'cone'` or `'berry'`),
|
|
230
309
|
`count` per outermost twig, `size`, `sizeVariation` and `hang` (0 = sits on the twig .. 1 = hangs
|
|
231
310
|
straight down). A fractional `count` is a chance per twig: `0.3` puts one Fruit on about 30% of the
|
|
@@ -343,6 +422,97 @@ if (hit) console.log(forest.treeAt(hit)?.key);
|
|
|
343
422
|
|
|
344
423
|
`forest.dispose()` frees everything. `forest.ready` resolves once its textures have loaded.
|
|
345
424
|
|
|
425
|
+
## Material Features
|
|
426
|
+
|
|
427
|
+

|
|
428
|
+
|
|
429
|
+
*The same tree and lights, without (left) and with (right) `SUGGESTED_MATERIAL_FEATURES.stylized`.*
|
|
430
|
+
|
|
431
|
+
Material Features make a crown read as one soft volume instead of a noise of leaf cards. There are
|
|
432
|
+
three, each an optional field in the Definition's `materials` section:
|
|
433
|
+
|
|
434
|
+
| Field | Range | What it does |
|
|
435
|
+
| --- | --- | --- |
|
|
436
|
+
| `materials.leaf.crownNormals` | 0..1 | **Crown Normals**: each leaf's normal is blended towards the [Crown Volume](#tree-definitions-and-seeds)'s, so the crown is lit as one rounded shape (0 = each leaf on its own .. 1 = fully). With flat shading the facets stay visible below 1. |
|
|
437
|
+
| `materials.leaf.translucency` | `{ strength, edge, ambient }`, each 0..1 | **Leaf Translucency**: leaves glow in their own Season colour when you look towards a light through them. `strength` per direct light (shadowed leaves don't glow), `edge` = how much more the thin edge of the crown glows than its inside, `ambient` = the sky shining through, dimmed by occlusion. Leaves only, never bark or Fruit. |
|
|
438
|
+
| `materials.occlusion` | `{ strength }`, 0..1 | **Structural Occlusion**: the inside of the crown and the trunk under it get less ambient light. Worked out once from the tree's shape (baked per vertex, the same for every Season), for wood, leaves and Fruit. Changing `strength` doesn't regenerate the tree. |
|
|
439
|
+
|
|
440
|
+
**They are strictly opt-in and pass-free.** Absent means off, and no built-in Style or Species turns one
|
|
441
|
+
on, so a game that sets nothing sees exactly the trees it saw before (same geometry, attributes and
|
|
442
|
+
materials). Turning one on only changes the tree's own node materials: your renderer, scene, lights and
|
|
443
|
+
post-processing are left alone, and there is no extra render pass, only some shader math per pixel. They
|
|
444
|
+
work in every Style (flat, standard and toon shading), with Growth and Wind, and in Forests.
|
|
445
|
+
|
|
446
|
+
Each Style has suggested values. Opt in with one line: `withMaterialFeatures(definition, features)`
|
|
447
|
+
returns a new Definition whose Material Features are exactly `features` (a feature you leave out is off,
|
|
448
|
+
`{}` turns them all off) and leaves its input unchanged:
|
|
449
|
+
|
|
450
|
+
```ts
|
|
451
|
+
import { createTree, SUGGESTED_MATERIAL_FEATURES, withMaterialFeatures } from '@casmo/tree.js';
|
|
452
|
+
import { oak } from '@casmo/tree.js/species';
|
|
453
|
+
import realistic from '@casmo/tree.js/styles/realistic';
|
|
454
|
+
import stylized from '@casmo/tree.js/styles/stylized';
|
|
455
|
+
|
|
456
|
+
const tree = createTree(withMaterialFeatures(stylized.broadleaf, SUGGESTED_MATERIAL_FEATURES.stylized), { seed: 3 });
|
|
457
|
+
|
|
458
|
+
// Or your own values, e.g. only a little crown shading and occlusion:
|
|
459
|
+
const subtle = withMaterialFeatures(realistic.apply(oak), { crownNormals: 0.4, occlusion: { strength: 0.5 } });
|
|
460
|
+
const off = withMaterialFeatures(subtle, {}); // the plain Style tree again
|
|
461
|
+
```
|
|
462
|
+
|
|
463
|
+
| Style | `crownNormals` | `translucency` | `occlusion` |
|
|
464
|
+
| --- | --- | --- | --- |
|
|
465
|
+
| `low-poly` | 0.5 | (off: it would soften the flat look) | `{ strength: 0.8 }` |
|
|
466
|
+
| `stylized` | 1 | `{ strength: 0.3, edge: 0.8, ambient: 0.2 }` | `{ strength: 0.9 }` |
|
|
467
|
+
| `realistic` | 0.6 | `{ strength: 0.45, edge: 0.7, ambient: 0.25 }` | `{ strength: 0.9 }` |
|
|
468
|
+
|
|
469
|
+
The fields are plain numbers, so they are saved in the Definition JSON (the Tree Editor exports them) and
|
|
470
|
+
can be set with `extendDefinition` too (`{ materials: { leaf: { crownNormals: 1 } } }`). Validation
|
|
471
|
+
rejects values outside 0..1.
|
|
472
|
+
|
|
473
|
+
**Tuning live.** A feature that is on can be retuned on a Tree or Forest without regenerating it: the
|
|
474
|
+
values are uniforms, so there is no new geometry and no recompile. Values are clamped to 0..1; setting a
|
|
475
|
+
feature that is off throws (switching one on or off needs a new Tree or Forest). A Baked Tree is baked
|
|
476
|
+
with the values as tuned.
|
|
477
|
+
|
|
478
|
+
```ts
|
|
479
|
+
import { createTree, SUGGESTED_MATERIAL_FEATURES, withMaterialFeatures } from '@casmo/tree.js';
|
|
480
|
+
import stylized from '@casmo/tree.js/styles/stylized';
|
|
481
|
+
|
|
482
|
+
const tree = createTree(withMaterialFeatures(stylized.broadleaf, SUGGESTED_MATERIAL_FEATURES.stylized));
|
|
483
|
+
tree.crownNormals = 0.8; // number | null (null = off)
|
|
484
|
+
tree.translucency = { strength: 0.6 }; // any of strength, edge, ambient; the others are kept
|
|
485
|
+
tree.occlusionStrength = 0.5; // number | null
|
|
486
|
+
tree.materialFeatures; // { crownNormals?, translucency?, occlusion? } as tuned now
|
|
487
|
+
```
|
|
488
|
+
|
|
489
|
+
**With your SSAO/GTAO.** Structural Occlusion is the materials' built-in ambient occlusion (`aoNode`),
|
|
490
|
+
so it darkens ambient and indirect light only (sunlit sides stay sunlit) and three.js multiplies it
|
|
491
|
+
with screen-space AO the same way it does for any material. Your SSAO pass needs no changes; trees simply
|
|
492
|
+
bring their own occlusion, including the inside of the crown, which screen-space AO can't see:
|
|
493
|
+
|
|
494
|
+
```ts
|
|
495
|
+
import * as THREE from 'three/webgpu';
|
|
496
|
+
import { builtinAOContext, mrt, normalView, output, pass, screenUV } from 'three/tsl';
|
|
497
|
+
import { ao } from 'three/addons/tsl/display/GTAONode.js';
|
|
498
|
+
|
|
499
|
+
const prePass = pass(scene, camera);
|
|
500
|
+
prePass.setMRT(mrt({ output, normal: normalView }));
|
|
501
|
+
const gtao = ao(prePass.getTextureNode('depth'), prePass.getTextureNode('normal'), camera);
|
|
502
|
+
|
|
503
|
+
const scenePass = pass(scene, camera);
|
|
504
|
+
// GTAO and the trees' Structural Occlusion are multiplied together, for ambient light only.
|
|
505
|
+
scenePass.contextNode = builtinAOContext(gtao.getTextureNode().sample(screenUV).r);
|
|
506
|
+
|
|
507
|
+
const pipeline = new THREE.RenderPipeline(renderer);
|
|
508
|
+
pipeline.outputNode = scenePass;
|
|
509
|
+
renderer.setAnimationLoop(() => pipeline.render());
|
|
510
|
+
```
|
|
511
|
+
|
|
512
|
+
Material Features are a different thing from [Tree Effects](#tree-effects): those are post-processing
|
|
513
|
+
(the "leaf glow" effect is a screen-space bloom, not Leaf Translucency). See them side by side per Style in
|
|
514
|
+
[`examples/material-features`](examples/material-features/main.ts).
|
|
515
|
+
|
|
346
516
|
## Tree Effects
|
|
347
517
|
|
|
348
518
|

|
|
@@ -505,6 +675,41 @@ const baked = bakeTree(tree, { season: 0.6 }); // a THREE.Group, e.g. for your o
|
|
|
505
675
|
disposeBakedTree(baked);
|
|
506
676
|
```
|
|
507
677
|
|
|
678
|
+
## Using a Baked Tree in other engines
|
|
679
|
+
|
|
680
|
+
A Baked Tree carries its Material Features (Crown Normals, Leaf Translucency, Structural Occlusion; see
|
|
681
|
+
`materials` in the Tree Definition) in standard glTF channels, so other engines can show them. With no
|
|
682
|
+
Material Feature set, the `.glb` is exactly what it was without them.
|
|
683
|
+
|
|
684
|
+
```ts
|
|
685
|
+
import { createTree, exportBakedTree, extendDefinition } from '@casmo/tree.js';
|
|
686
|
+
|
|
687
|
+
const definition = extendDefinition({ schemaVersion: 3 }, {
|
|
688
|
+
materials: { leaf: { crownNormals: 1, translucency: { strength: 0.5, edge: 0.6, ambient: 0.3 } }, occlusion: { strength: 0.7 } },
|
|
689
|
+
});
|
|
690
|
+
const tree = createTree(definition, { seed: 4 });
|
|
691
|
+
const glb = await exportBakedTree(tree, { occlusionInVertexColors: true }); // the option works for bakeTree too
|
|
692
|
+
```
|
|
693
|
+
|
|
694
|
+
| glTF channel | What it holds | Unity | Godot 4 | Unreal | Blender |
|
|
695
|
+
| --- | --- | --- | --- | --- | --- |
|
|
696
|
+
| `NORMAL` | Crown Normals already blended in (flat shading: the facet normals, blended by the same amount). Flat leaf cards (`leaves.shape: 'card'`) are turned (normal and winding together) to face outward of the Crown Volume, so engines that flip the normal of back faces still light every card from the crown's outside. Solid leaf shapes keep their winding. | Imported as mesh normals; keep the importer from recalculating them. | Imported as mesh normals. | Imported as mesh normals; turn "Recompute Normals" off. | Imported as custom normals. |
|
|
697
|
+
| `_OCCLUSION` (float, 0..1, all meshes) | Structural Occlusion as the tree shows it: `mix(1, aOcclusion, strength)`, 0 = occluded. **Final: the strength is already applied**, use it as AO as it is. Only when `materials.occlusion` is set. | Custom attributes are not imported by default: copy it into a UV channel or vertex colour in a custom importer, then feed it to the shader's occlusion. Or use `COLOR_0` (below). | Copy it into `CUSTOM0` with a `GLTFDocumentExtension` and read it as `AO` in a `ShaderMaterial`. Or use `COLOR_0`. | Not imported: use `COLOR_0`. | Imported as a mesh attribute `_OCCLUSION`: an Attribute node, multiplied into the indirect light or the Base Color. |
|
|
698
|
+
| `COLOR_0` | The vertex colours (Season colour, bark shading) as without the features; times `_OCCLUSION` with `occlusionInVertexColors: true`. | A shader that multiplies vertex colour into albedo (glTFast's shaders do). | `vertex_color_use_as_albedo` on the material. | Vertex Color node into Base Color. | Color Attribute node into Base Color (the importer wires it). |
|
|
699
|
+
| `KHR_materials_diffuse_transmission` (leaf material) | Leaf Translucency: `diffuseTransmissionFactor` = strength, `diffuseTransmissionColorFactor` = the leaf colour (linear, mean at the baked Season). | A foliage or translucent shader: transmission or thickness from the factor, colour from the colour factor. | `backlight_enabled`, `backlight` = colour × factor. | Shading model Two Sided Foliage, Subsurface Color = colour × factor. | Mix a Translucent BSDF (the colour) into the leaf shader by the factor. |
|
|
700
|
+
| `extras.treejs` (leaf and bark materials) | The settings `crownNormals`, `translucency { strength, edge, ambient }`, `occlusion { strength, strengthApplied: true, inVertexColors }` (only those set) and the Crown Volume `crown { center, radii }` in the Baked Tree's space (scaled by its Growth). `occlusion.strength` is for reference: `strengthApplied: true` says `_OCCLUSION` already has it, and `inVertexColors` whether `COLOR_0` has the occlusion too. | Read the glTF JSON in a custom importer to rebuild the effects in your own shader. | Imported as metadata on the material (`extras`), or read in a `GLTFDocumentExtension`. | Not imported: read the glTF JSON. | Imported as custom properties of the material. |
|
|
701
|
+
|
|
702
|
+
Importer support differs between versions; the columns show where each value goes.
|
|
703
|
+
|
|
704
|
+
**Don't apply the occlusion strength twice:** `_OCCLUSION` (and `COLOR_0` with `occlusionInVertexColors`)
|
|
705
|
+
already has `materials.occlusion.strength` applied. Use `_OCCLUSION` as AO directly, and only read
|
|
706
|
+
`extras.treejs.occlusion.strength` if you rebuild the effect from scratch.
|
|
707
|
+
|
|
708
|
+
**`occlusionInVertexColors`** (default `false`, in `bakeTree` and `exportBakedTree`): engines that only read
|
|
709
|
+
vertex colours show the occlusion without a custom shader. The trade-off: `COLOR_0` darkens all light,
|
|
710
|
+
direct sunlight included, while Structural Occlusion in tree.js (and `_OCCLUSION` used as AO) darkens only
|
|
711
|
+
ambient and indirect light. Leave it off when your engine can read `_OCCLUSION`, or keep the strength lower.
|
|
712
|
+
|
|
508
713
|
## Textures
|
|
509
714
|
|
|
510
715
|

|
|
@@ -548,6 +753,7 @@ a live preview (Seed, Growth, Season, Wind, Tree Effects), sculpt single branche
|
|
|
548
753
|
| [`examples/react`](examples/react/main.tsx) | `/examples/react/` | React Three Fiber: `<Tree>`, `<Wind>`, `useTreeStyle`; `?scene=forest` for `<Forest>` | <img src="docs/images/example-react.png" alt="examples/react" width="160"> |
|
|
549
754
|
| [`examples/forest`](examples/forest/main.ts) | `/examples/forest/` | a 400-tree Forest; `?trees=&variants=&style=&season=` | <img src="docs/images/example-forest.png" alt="examples/forest" width="160"> |
|
|
550
755
|
| [`examples/effects`](examples/effects/main.ts) | `/examples/effects/` | Tree Effects per Style; `?style=stylized&effects=outline` | <img src="docs/images/example-effects.png" alt="examples/effects" width="160"> |
|
|
756
|
+
| [`examples/material-features`](examples/material-features/main.ts) | `/examples/material-features/` | the same tree with Material Features off and on (`SUGGESTED_MATERIAL_FEATURES`); `?style=realistic&species=oak` | <img src="docs/images/example-material-features.png" alt="examples/material-features" width="160"> |
|
|
551
757
|
| [`examples/species`](examples/species/main.ts) | `/examples/species/` | a Species x Style picker over the whole collection; `?species=douglas-fir&style=realistic` | <img src="docs/images/example-species.png" alt="examples/species" width="160"> |
|
|
552
758
|
|
|
553
759
|
```sh
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as extendDefinition, i as styleShading, o as materialFeaturesOf, r as styleOfShading, u as parseDefinition } from "./names-BE9he6CS.js";
|
|
2
2
|
// src/styles/realistic/textures.ts
|
|
3
3
|
/**
|
|
4
4
|
* The realistic Style's texture files, as relative URLs (resolved against the texture base path).
|
|
@@ -59,7 +59,8 @@ var LOOKS = {
|
|
|
59
59
|
"low-poly": {
|
|
60
60
|
trunk: {
|
|
61
61
|
sides: 5,
|
|
62
|
-
sections: 4
|
|
62
|
+
sections: 4,
|
|
63
|
+
flareSections: 2
|
|
63
64
|
},
|
|
64
65
|
branches: [{
|
|
65
66
|
sides: 4,
|
|
@@ -70,6 +71,10 @@ var LOOKS = {
|
|
|
70
71
|
}],
|
|
71
72
|
bark: untexturedBark,
|
|
72
73
|
fruitSides: 4,
|
|
74
|
+
roots: {
|
|
75
|
+
sides: 3,
|
|
76
|
+
sections: 2
|
|
77
|
+
},
|
|
73
78
|
leaf: (type) => isNeedleLike(type) ? {
|
|
74
79
|
shape: "needle",
|
|
75
80
|
perDensity: 14,
|
|
@@ -85,7 +90,8 @@ var LOOKS = {
|
|
|
85
90
|
stylized: {
|
|
86
91
|
trunk: {
|
|
87
92
|
sides: 10,
|
|
88
|
-
sections: 8
|
|
93
|
+
sections: 8,
|
|
94
|
+
flareSections: 3
|
|
89
95
|
},
|
|
90
96
|
branches: [
|
|
91
97
|
{
|
|
@@ -103,6 +109,10 @@ var LOOKS = {
|
|
|
103
109
|
],
|
|
104
110
|
bark: untexturedBark,
|
|
105
111
|
fruitSides: 6,
|
|
112
|
+
roots: {
|
|
113
|
+
sides: 6,
|
|
114
|
+
sections: 4
|
|
115
|
+
},
|
|
106
116
|
leaf: (type) => isNeedleLike(type) ? {
|
|
107
117
|
shape: "puff",
|
|
108
118
|
perDensity: 8,
|
|
@@ -118,7 +128,8 @@ var LOOKS = {
|
|
|
118
128
|
realistic: {
|
|
119
129
|
trunk: {
|
|
120
130
|
sides: 12,
|
|
121
|
-
sections: 10
|
|
131
|
+
sections: 10,
|
|
132
|
+
flareSections: 3
|
|
122
133
|
},
|
|
123
134
|
branches: [
|
|
124
135
|
{
|
|
@@ -139,6 +150,10 @@ var LOOKS = {
|
|
|
139
150
|
...BARK_TEXTURES[type]
|
|
140
151
|
}),
|
|
141
152
|
fruitSides: 9,
|
|
153
|
+
roots: {
|
|
154
|
+
sides: 8,
|
|
155
|
+
sections: 6
|
|
156
|
+
},
|
|
142
157
|
leaf: (type) => isNeedleLike(type) ? {
|
|
143
158
|
shape: "card",
|
|
144
159
|
perDensity: 120,
|
|
@@ -160,8 +175,12 @@ var LOOKS = {
|
|
|
160
175
|
}
|
|
161
176
|
}
|
|
162
177
|
};
|
|
178
|
+
/** `{ [key]: value }` for an optional block that is present, `{}` when it is absent (to spread). */
|
|
179
|
+
function present(key, value) {
|
|
180
|
+
return value === void 0 ? {} : { [key]: value };
|
|
181
|
+
}
|
|
163
182
|
function fromSpecies(species) {
|
|
164
|
-
const { id, name, trunk, branches, season, wind, variation, fruit, foliage, bark } = species;
|
|
183
|
+
const { id, name, trunk, branches, season, wind, variation, fruit, roots, foliage, bark } = species;
|
|
165
184
|
return {
|
|
166
185
|
base: {
|
|
167
186
|
schemaVersion: 3,
|
|
@@ -173,14 +192,17 @@ function fromSpecies(species) {
|
|
|
173
192
|
wind,
|
|
174
193
|
variation,
|
|
175
194
|
sculpts: [],
|
|
176
|
-
...fruit
|
|
195
|
+
...present("fruit", fruit),
|
|
196
|
+
...present("roots", roots)
|
|
177
197
|
},
|
|
178
198
|
foliage,
|
|
179
|
-
bark
|
|
199
|
+
bark,
|
|
200
|
+
features: {}
|
|
180
201
|
};
|
|
181
202
|
}
|
|
182
203
|
function fromDefinition(input) {
|
|
183
|
-
const
|
|
204
|
+
const definition = parseDefinition(input);
|
|
205
|
+
const { leaves, materials, ...base } = definition;
|
|
184
206
|
const leafType = leaves.type ?? (leaves.shape === "needle" || /needle/.test(materials.leaf.map ?? "") ? "needle" : "broad");
|
|
185
207
|
const source = LOOKS[styleOfShading(materials.shading)].leaf(leafType);
|
|
186
208
|
return {
|
|
@@ -195,20 +217,27 @@ function fromDefinition(input) {
|
|
|
195
217
|
},
|
|
196
218
|
bark: {
|
|
197
219
|
type: materials.bark.type ?? "furrowed",
|
|
198
|
-
color: materials.bark.color
|
|
199
|
-
|
|
220
|
+
color: materials.bark.color,
|
|
221
|
+
...present("groundTint", materials.bark.groundTint)
|
|
222
|
+
},
|
|
223
|
+
features: materialFeaturesOf(definition)
|
|
200
224
|
};
|
|
201
225
|
}
|
|
202
|
-
function draw(name, { base, foliage, bark }) {
|
|
226
|
+
function draw(name, { base, foliage, bark, features }) {
|
|
203
227
|
const look = LOOKS[name];
|
|
204
228
|
const leaf = look.leaf(foliage.type);
|
|
205
229
|
const fruit = base.fruit;
|
|
230
|
+
const roots = base.roots;
|
|
206
231
|
return parseDefinition({
|
|
207
232
|
...base,
|
|
208
|
-
...fruit
|
|
233
|
+
...present("fruit", fruit && {
|
|
209
234
|
...fruit,
|
|
210
235
|
sides: look.fruitSides
|
|
211
|
-
}
|
|
236
|
+
}),
|
|
237
|
+
...present("roots", roots && {
|
|
238
|
+
...roots,
|
|
239
|
+
...look.roots
|
|
240
|
+
}),
|
|
212
241
|
trunk: {
|
|
213
242
|
...base.trunk,
|
|
214
243
|
...look.trunk
|
|
@@ -231,9 +260,15 @@ function draw(name, { base, foliage, bark }) {
|
|
|
231
260
|
bark: {
|
|
232
261
|
type: bark.type,
|
|
233
262
|
color: bark.color,
|
|
234
|
-
...look.bark(bark.type)
|
|
263
|
+
...look.bark(bark.type),
|
|
264
|
+
...present("groundTint", bark.groundTint)
|
|
265
|
+
},
|
|
266
|
+
leaf: {
|
|
267
|
+
...leaf.material,
|
|
268
|
+
...present("crownNormals", features.crownNormals),
|
|
269
|
+
...present("translucency", features.translucency)
|
|
235
270
|
},
|
|
236
|
-
|
|
271
|
+
...present("occlusion", features.occlusion)
|
|
237
272
|
}
|
|
238
273
|
});
|
|
239
274
|
}
|
|
@@ -247,4 +282,4 @@ function applyStyle(name, source, overrides) {
|
|
|
247
282
|
}
|
|
248
283
|
export { TEXTURES as i, BARK_TEXTURES as n, LEAF_TEXTURES as r, applyStyle as t };
|
|
249
284
|
|
|
250
|
-
//# sourceMappingURL=apply-
|
|
285
|
+
//# sourceMappingURL=apply-Cio2t7CZ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apply-Cio2t7CZ.js","names":[],"sources":["../src/styles/realistic/textures.ts","../src/styles/apply.ts"],"sourcesContent":["import type { BarkType, LeafType } from '../../definition/types';\n\n/**\n * The realistic Style's texture files, as relative URLs (resolved against the texture base path).\n * All made by scripts/generate-textures.mjs. `bark`/`barkNormal` are the furrowed pair, `leaf` the\n * broad card and `needles` the needle card (the generic broadleaf / conifer use these).\n */\nexport const TEXTURES = {\n bark: 'realistic/bark.png',\n barkNormal: 'realistic/bark-normal.png',\n leaf: 'realistic/leaf.png',\n needles: 'realistic/needles.png',\n} as const;\n\n/** The alpha-cut leaf card texture for each Leaf Type. */\nexport const LEAF_TEXTURES: Readonly<Record<LeafType, string>> = {\n broad: TEXTURES.leaf,\n lobed: 'realistic/leaf-lobed.png',\n palmate: 'realistic/leaf-palmate.png',\n compound: 'realistic/leaf-compound.png',\n needle: TEXTURES.needles,\n scale: 'realistic/scale.png',\n};\n\n/** The colour + normal map pair for each Bark Type. */\nexport const BARK_TEXTURES: Readonly<Record<BarkType, { map: string; normalMap: string }>> = {\n furrowed: { map: TEXTURES.bark, normalMap: TEXTURES.barkNormal },\n smooth: { map: 'realistic/bark-smooth.png', normalMap: 'realistic/bark-smooth-normal.png' },\n papery: { map: 'realistic/bark-papery.png', normalMap: 'realistic/bark-papery-normal.png' },\n fibrous: { map: 'realistic/bark-fibrous.png', normalMap: 'realistic/bark-fibrous-normal.png' },\n plated: { map: 'realistic/bark-plated.png', normalMap: 'realistic/bark-plated-normal.png' },\n};\n","// Style.apply (ADR 0005): a Style turns a Style-neutral Species (or an existing Tree Definition)\n// into a complete Tree Definition by choosing only the look: shading, polygon detail, how the\n// Leaf Type and Bark Type are drawn, and textures. Shape fields pass through untouched.\nimport { extendDefinition, parseDefinition, type DefinitionPatch } from '../definition/parse';\nimport {\n CURRENT_SCHEMA_VERSION,\n type BarkMaterialDefinition,\n type MaterialFeatures,\n type BarkType,\n type LeafMaterialDefinition,\n type LeafShape,\n type LeafType,\n type TreeDefinition,\n type TreeDefinitionInput,\n} from '../definition/types';\nimport type { SpeciesBarkDefinition, SpeciesDefinition, SpeciesFoliageDefinition } from '../species/types';\nimport { styleOfShading, styleShading, type StyleName } from './names';\nimport { materialFeaturesOf } from './material-features';\nimport { BARK_TEXTURES, LEAF_TEXTURES } from './realistic/textures';\n\n/** Polygon detail of one tree part. */\ninterface Detail {\n sides: number;\n sections: number;\n}\n\n/** How a Style draws one Leaf Type. */\ninterface LeafLook {\n shape: LeafShape;\n /** Leaves per terminal branch at density 1 (count = round(density × this)). */\n perDensity: number;\n /** Leaf size = the Species' real leaf-spray size × this. */\n sizeScale: number;\n material: LeafMaterialDefinition;\n}\n\n/** The trunk's detail, plus the extra rings in its Root Flare (`trunk.flareSections`). */\ninterface TrunkDetail extends Detail {\n flareSections: number;\n}\n\n/** Everything a Style decides about a tree: its look (its shading is in names.ts). */\ninterface StyleLook {\n trunk: TrunkDetail;\n /** Detail per branch level; deeper levels reuse the last entry. */\n branches: Detail[];\n bark(type: BarkType): Omit<BarkMaterialDefinition, 'type' | 'color'>;\n leaf(type: LeafType): LeafLook;\n /** Faces around each Fruit (`fruit.sides`): few flat facets in low-poly, smooth in the others. */\n fruitSides: number;\n /** Detail of each Root (`roots.sides`, `roots.sections`). */\n roots: Detail;\n}\n\nconst isNeedleLike = (type: LeafType) => type === 'needle' || type === 'scale';\nconst untexturedLeaf: LeafMaterialDefinition = { roughness: 1, map: null, alphaTest: 0.5 };\nconst untexturedBark = () => ({ roughness: 1, map: null, normalMap: null });\n\n// Low-poly and stylized are calibrated so a Species with density 0.5 and leaf-spray size 0.35 m comes\n// out close to each Style's own broadleaf / conifer Definitions. Realistic draws far more (cheap, 2\n// triangle) cards per twig than its own Definitions: a Species has fewer twigs than the realistic\n// generic trees (the low-poly and stylized triangle budgets cap them at about 40-90), so the cards\n// have to fill the crown. Deeper branch levels get little detail (twigs are thin and many).\nconst LOOKS = {\n 'low-poly': {\n trunk: { sides: 5, sections: 4, flareSections: 2 },\n branches: [{ sides: 4, sections: 2 }, { sides: 3, sections: 1 }],\n bark: untexturedBark,\n fruitSides: 4,\n roots: { sides: 3, sections: 2 },\n leaf: (type) =>\n isNeedleLike(type)\n ? { shape: 'needle', perDensity: 14, sizeScale: 1.86, material: untexturedLeaf }\n : { shape: 'clump', perDensity: 4, sizeScale: 2.86, material: untexturedLeaf },\n },\n stylized: {\n trunk: { sides: 10, sections: 8, flareSections: 3 },\n branches: [{ sides: 6, sections: 3 }, { sides: 4, sections: 1 }, { sides: 3, sections: 1 }],\n bark: untexturedBark,\n fruitSides: 6,\n roots: { sides: 6, sections: 4 },\n // All puffs; smaller and denser for needle / scale foliage.\n leaf: (type) =>\n isNeedleLike(type)\n ? { shape: 'puff', perDensity: 8, sizeScale: 1.7, material: untexturedLeaf }\n : { shape: 'puff', perDensity: 4, sizeScale: 3.14, material: untexturedLeaf },\n },\n realistic: {\n trunk: { sides: 12, sections: 10, flareSections: 3 },\n branches: [{ sides: 8, sections: 6 }, { sides: 5, sections: 4 }, { sides: 3, sections: 2 }],\n // A texture per Bark Type and per Leaf Type (scripts/generate-textures.mjs).\n bark: (type) => ({ roughness: 0.95, ...BARK_TEXTURES[type] }),\n fruitSides: 9,\n roots: { sides: 8, sections: 6 },\n leaf: (type) =>\n isNeedleLike(type)\n ? { shape: 'card', perDensity: 120, sizeScale: 1.7, material: { roughness: 0.7, map: LEAF_TEXTURES[type], alphaTest: 0.4 } }\n : { shape: 'card', perDensity: 80, sizeScale: 2.2, material: { roughness: 0.65, map: LEAF_TEXTURES[type], alphaTest: 0.4 } },\n },\n} satisfies Record<StyleName, StyleLook>;\n\n/** What `Style.apply` accepts: a Species, or a Tree Definition to re-style. */\nexport type StyleSource = SpeciesDefinition | TreeDefinition | TreeDefinitionInput;\n\n/** `{ [key]: value }` for an optional block that is present, `{}` when it is absent (to spread). */\nfunction present<K extends string, V>(key: K, value: V | undefined): { [P in K]?: V } {\n return value === undefined ? {} : ({ [key]: value } as { [P in K]?: V });\n}\n\n/** The Style-neutral content of a source: every non-look field, plus foliage and bark. */\ninterface Neutral {\n /** Definition fields that pass through (shape, Season, Wind, Sculpts, Fruit, Roots, ...). */\n base: Record<string, unknown> & { trunk: object; branches: object[] };\n foliage: SpeciesFoliageDefinition;\n /** A Definition's Ground Tint passes through too: it is not part of a Style's look. */\n bark: SpeciesBarkDefinition & Pick<BarkMaterialDefinition, 'groundTint'>;\n /** A Definition's Material Features pass through too (ADR 0008): they are the app's choice, never a Style's. */\n features: MaterialFeatures;\n}\n\nfunction fromSpecies(species: SpeciesDefinition): Neutral {\n const { id, name, trunk, branches, season, wind, variation, fruit, roots, foliage, bark } = species;\n return {\n base: {\n schemaVersion: CURRENT_SCHEMA_VERSION,\n name,\n species: id,\n trunk,\n branches,\n season,\n wind,\n variation,\n sculpts: [],\n ...present('fruit', fruit),\n ...present('roots', roots),\n },\n foliage,\n bark,\n features: {},\n };\n}\n\nfunction fromDefinition(input: TreeDefinition | TreeDefinitionInput): Neutral {\n const definition = parseDefinition(input);\n const { leaves, materials, ...base } = definition;\n // Definitions not made by `apply` carry no Leaf / Bark Type: guess them from how they are drawn.\n const leafType = leaves.type ?? (leaves.shape === 'needle' || /needle/.test(materials.leaf.map ?? '') ? 'needle' : 'broad');\n const source = LOOKS[styleOfShading(materials.shading)].leaf(leafType);\n return {\n base,\n foliage: {\n type: leafType,\n density: leaves.count / source.perDensity,\n size: leaves.size / source.sizeScale,\n sizeVariation: leaves.sizeVariation,\n start: leaves.start,\n angle: leaves.angle,\n },\n bark: {\n type: materials.bark.type ?? 'furrowed',\n color: materials.bark.color,\n ...present('groundTint', materials.bark.groundTint),\n },\n features: materialFeaturesOf(definition),\n };\n}\n\nfunction draw(name: StyleName, { base, foliage, bark, features }: Neutral): TreeDefinition {\n const look: StyleLook = LOOKS[name];\n const leaf = look.leaf(foliage.type);\n const fruit = base.fruit as TreeDefinition['fruit'];\n const roots = base.roots as TreeDefinition['roots'];\n return parseDefinition({\n ...base,\n ...present('fruit', fruit && { ...fruit, sides: look.fruitSides }),\n ...present('roots', roots && { ...roots, ...look.roots }),\n trunk: { ...base.trunk, ...look.trunk },\n branches: base.branches.map((level, i) => ({ ...level, ...look.branches[Math.min(i, look.branches.length - 1)] })),\n leaves: {\n type: foliage.type,\n count: Math.round(foliage.density * leaf.perDensity),\n shape: leaf.shape,\n size: foliage.size * leaf.sizeScale,\n sizeVariation: foliage.sizeVariation,\n start: foliage.start,\n angle: foliage.angle,\n },\n materials: {\n shading: styleShading(name),\n bark: { type: bark.type, color: bark.color, ...look.bark(bark.type), ...present('groundTint', bark.groundTint) },\n leaf: { ...leaf.material, ...present('crownNormals', features.crownNormals), ...present('translucency', features.translucency) },\n ...present('occlusion', features.occlusion),\n },\n });\n}\n\n/**\n * Applies a built-in Style's look to a Species or a Tree Definition (see `TreeStyle.apply`).\n * Pure: never mutates its inputs.\n */\nexport function applyStyle(name: StyleName, source: StyleSource, overrides?: DefinitionPatch): TreeDefinition {\n const neutral = 'schemaVersion' in source ? fromDefinition(source) : fromSpecies(source);\n const definition = draw(name, neutral);\n return overrides ? extendDefinition(definition, overrides) : definition;\n}\n"],"mappings":"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"}
|
package/dist/bake/index.d.ts
CHANGED
|
@@ -1,23 +1,62 @@
|
|
|
1
1
|
import { Group } from 'three/webgpu';
|
|
2
|
+
import type { TranslucencyDefinition } from '../definition';
|
|
3
|
+
import { type CrownVolume } from '../generator';
|
|
2
4
|
import type { Tree } from '../tree';
|
|
3
5
|
/**
|
|
4
6
|
* Baked Tree: one tree frozen at a Seed, Growth and Season as plain static geometry with
|
|
5
|
-
* standard PBR materials (`MeshStandardMaterial`, no node materials,
|
|
6
|
-
*
|
|
7
|
-
*
|
|
7
|
+
* standard PBR materials (`MeshStandardMaterial`, no node materials), for glTF export and other tools.
|
|
8
|
+
* Growth and Season are evaluated on the CPU with the same models the shaders run (`growPositions`,
|
|
9
|
+
* `leafSeason`, `fruitSeason`); Wind is left out (a Baked Tree stands still).
|
|
10
|
+
*
|
|
11
|
+
* Material Features (ADR 0008) are baked into standard glTF channels: Crown Normals blended into the normals,
|
|
12
|
+
* Structural Occlusion as a `_occlusion` attribute (glTF `_OCCLUSION`, strength already applied; optionally also in the vertex
|
|
13
|
+
* colours), Leaf Translucency as `KHR_materials_diffuse_transmission` (written by `exportBakedTree`),
|
|
14
|
+
* and the settings with the Crown Volume in `userData.treejs` of the leaf and bark materials (glTF
|
|
15
|
+
* `extras`). With no Material Feature set, the result is exactly as without them.
|
|
8
16
|
*/
|
|
9
17
|
/** Growth and Season to bake at; each defaults to the tree's current value. */
|
|
10
18
|
export interface BakeOptions {
|
|
11
19
|
growth?: number;
|
|
12
20
|
season?: number;
|
|
21
|
+
/**
|
|
22
|
+
* With Structural Occlusion (`materials.occlusion`): also multiply the occlusion into the vertex
|
|
23
|
+
* colours (`COLOR_0`), for engines that only read vertex colours. It then darkens direct light too.
|
|
24
|
+
* Default false: `COLOR_0` is as without the feature, and the occlusion is only in `_OCCLUSION`.
|
|
25
|
+
*/
|
|
26
|
+
occlusionInVertexColors?: boolean;
|
|
13
27
|
}
|
|
14
28
|
/**
|
|
15
29
|
* Freezes a tree at a Growth and Season (default: the tree's own) into a static `Group` of
|
|
16
30
|
* meshes `wood`, `leaves` and `fruit` (a mesh with nothing to show is left out) with standard PBR
|
|
17
|
-
* materials: no node materials, no Growth/Season/Wind attributes, no animation.
|
|
31
|
+
* materials: no node materials, no Growth/Season/Wind attributes, no animation. Material Features
|
|
32
|
+
* are baked in (see the top of this module). The result is
|
|
18
33
|
* independent of `tree`; call `disposeBakedTree` when done with it.
|
|
19
34
|
*/
|
|
20
35
|
export declare function bakeTree(tree: Tree, options?: BakeOptions): Group;
|
|
36
|
+
/**
|
|
37
|
+
* The `treejs` object in the extras of the baked leaf and bark materials: the Material Feature
|
|
38
|
+
* settings and the Crown Volume, for engines that rebuild the effects in their own shaders. The Crown
|
|
39
|
+
* Volume is in the Baked Tree's space (scaled by its Growth, like the geometry). Null when the tree has
|
|
40
|
+
* no Material Feature, so its glTF is as without them.
|
|
41
|
+
*/
|
|
42
|
+
export interface MaterialFeatureExtras {
|
|
43
|
+
/** Crown Normals amount; the baked `NORMAL` already has them blended in. */
|
|
44
|
+
crownNormals?: number;
|
|
45
|
+
/** Leaf Translucency settings (also written as `KHR_materials_diffuse_transmission`). */
|
|
46
|
+
translucency?: TranslucencyDefinition;
|
|
47
|
+
occlusion?: {
|
|
48
|
+
/** The Structural Occlusion strength the tree had. */
|
|
49
|
+
strength: number;
|
|
50
|
+
/**
|
|
51
|
+
* Always true: the baked `_OCCLUSION` is final, `mix(1, aOcclusion, strength)`, with the strength
|
|
52
|
+
* already applied. Use it as AO as it is; do not apply `strength` again.
|
|
53
|
+
*/
|
|
54
|
+
strengthApplied: true;
|
|
55
|
+
/** Whether `COLOR_0` is also multiplied by `_OCCLUSION` (`occlusionInVertexColors`). */
|
|
56
|
+
inVertexColors: boolean;
|
|
57
|
+
};
|
|
58
|
+
crown: CrownVolume;
|
|
59
|
+
}
|
|
21
60
|
/** Frees the geometries, materials and texture copies of a baked tree. */
|
|
22
61
|
export declare function disposeBakedTree(baked: Group): void;
|
|
23
62
|
export interface ExportBakedTreeOptions extends BakeOptions {
|
package/dist/bake/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bake/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bake/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,EAKN,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAoB,sBAAsB,EAAkB,MAAM,eAAe,CAAC;AAC9F,OAAO,EAAe,KAAK,WAAW,EAAwB,MAAM,cAAc,CAAC;AAMnF,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAEpC;;;;;;;;;;;GAWG;AAEH,+EAA+E;AAC/E,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;OAIG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC;AA4SD;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,GAAE,WAAgB,GAAG,KAAK,CAkErE;AAED;;;;;GAKG;AACH,MAAM,WAAW,qBAAqB;IACpC,4EAA4E;IAC5E,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,yFAAyF;IACzF,YAAY,CAAC,EAAE,sBAAsB,CAAC;IACtC,SAAS,CAAC,EAAE;QACV,sDAAsD;QACtD,QAAQ,EAAE,MAAM,CAAC;QACjB;;;WAGG;QACH,eAAe,EAAE,IAAI,CAAC;QACtB,wFAAwF;QACxF,cAAc,EAAE,OAAO,CAAC;KACzB,CAAC;IACF,KAAK,EAAE,WAAW,CAAC;CACpB;AA4CD,0EAA0E;AAC1E,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CASnD;AAED,MAAM,WAAW,sBAAuB,SAAQ,WAAW;IACzD,2EAA2E;IAC3E,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG;IAAE,MAAM,CAAC,EAAE,IAAI,CAAA;CAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;AACxH,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,sBAAsB,GAAG;IAAE,MAAM,EAAE,KAAK,CAAA;CAAE,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AACnI,wBAAgB,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC"}
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import { type BranchLevelDefinition, type FruitDefinition, type HexColor, type Keyframe, type TreeDefinition } from './types';
|
|
1
|
+
import { type BranchLevelDefinition, type FruitDefinition, type GroundTintDefinition, type HexColor, type Keyframe, type OcclusionDefinition, type RootsDefinition, type TranslucencyDefinition, type TreeDefinition } from './types';
|
|
2
2
|
/** Defaults for one branching level; fills fields missing from a partial `branches[i]`. */
|
|
3
3
|
export declare const DEFAULT_BRANCH_LEVEL: BranchLevelDefinition;
|
|
4
4
|
/** Defaults for the fields of a `fruit` block (a Definition has no Fruit unless it has the block). */
|
|
5
5
|
export declare const DEFAULT_FRUIT: FruitDefinition;
|
|
6
|
+
/** Defaults for the fields of a `roots` block (a Definition has no Roots unless it has the block). */
|
|
7
|
+
export declare const DEFAULT_ROOTS: RootsDefinition;
|
|
8
|
+
/** Defaults for the fields of a `materials.bark.groundTint` block (no Ground Tint unless it has the block). */
|
|
9
|
+
export declare const DEFAULT_GROUND_TINT: GroundTintDefinition;
|
|
10
|
+
/** Defaults for the fields of a partial `materials.leaf.translucency` block (no Leaf Translucency unless it has the block). */
|
|
11
|
+
export declare const DEFAULT_TRANSLUCENCY: TranslucencyDefinition;
|
|
12
|
+
/** Defaults for the fields of a partial `materials.occlusion` block (no Structural Occlusion unless it has the block). */
|
|
13
|
+
export declare const DEFAULT_OCCLUSION: OcclusionDefinition;
|
|
6
14
|
/** Fruit amount when the Season Profile has no `fruit` track: all Fruit at full size all year. */
|
|
7
15
|
export declare const DEFAULT_FRUIT_AMOUNT: Keyframe<number>[];
|
|
8
16
|
/** Fruit colour when the Season Profile has no `fruitColor` track. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/definition/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,cAAc,EACpB,MAAM,SAAS,CAAC;AAEjB,2FAA2F;AAC3F,eAAO,MAAM,oBAAoB,EAAE,qBAelC,CAAC;AAEF,sGAAsG;AACtG,eAAO,MAAM,aAAa,EAAE,eAM3B,CAAC;AAEF,kGAAkG;AAClG,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAyB,CAAC;AAE7E,sEAAsE;AACtE,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAAiC,CAAC;AAEtF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,cAoDhC,CAAC"}
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../src/definition/defaults.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,qBAAqB,EAC1B,KAAK,eAAe,EACpB,KAAK,oBAAoB,EACzB,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,mBAAmB,EACxB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,KAAK,cAAc,EACpB,MAAM,SAAS,CAAC;AAEjB,2FAA2F;AAC3F,eAAO,MAAM,oBAAoB,EAAE,qBAelC,CAAC;AAEF,sGAAsG;AACtG,eAAO,MAAM,aAAa,EAAE,eAM3B,CAAC;AAEF,sGAAsG;AACtG,eAAO,MAAM,aAAa,EAAE,eAO3B,CAAC;AAEF,+GAA+G;AAC/G,eAAO,MAAM,mBAAmB,EAAE,oBAIjC,CAAC;AAEF,+HAA+H;AAC/H,eAAO,MAAM,oBAAoB,EAAE,sBAIlC,CAAC;AAEF,0HAA0H;AAC1H,eAAO,MAAM,iBAAiB,EAAE,mBAE/B,CAAC;AAEF,kGAAkG;AAClG,eAAO,MAAM,oBAAoB,EAAE,QAAQ,CAAC,MAAM,CAAC,EAAyB,CAAC;AAE7E,sEAAsE;AACtE,eAAO,MAAM,mBAAmB,EAAE,QAAQ,CAAC,QAAQ,CAAC,EAAiC,CAAC;AAEtF;;;GAGG;AACH,eAAO,MAAM,kBAAkB,EAAE,cAoDhC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { BARK_TYPES, CURRENT_SCHEMA_VERSION, FRUIT_TYPES, LEAF_TYPES, MAX_BRANCH_LEVELS } from './types';
|
|
2
|
-
export type { TreeDefinition, TreeDefinitionInput, DeepPartial, HexColor, Vec3Tuple, TreeForm, TrunkDefinition, BranchLevelDefinition, LeafShape, LeafType, BarkType, LeavesDefinition, FruitType, FruitDefinition, Shading, MaterialsDefinition, BarkMaterialDefinition, LeafMaterialDefinition, Keyframe, SeasonProfileDefinition, WindResponseDefinition, VariationDefinition, Sculpt, DeleteSculpt, MoveSculpt, LeavesSculpt, } from './types';
|
|
2
|
+
export type { TreeDefinition, TreeDefinitionInput, DeepPartial, HexColor, Vec3Tuple, TreeForm, TrunkDefinition, BranchLevelDefinition, LeafShape, LeafType, BarkType, LeavesDefinition, FruitType, FruitDefinition, RootsDefinition, Shading, MaterialsDefinition, BarkMaterialDefinition, GroundTintDefinition, LeafMaterialDefinition, MaterialFeatures, TranslucencyDefinition, OcclusionDefinition, Keyframe, SeasonProfileDefinition, WindResponseDefinition, VariationDefinition, Sculpt, DeleteSculpt, MoveSculpt, LeavesSculpt, } from './types';
|
|
3
3
|
export { coneCurve } from './crown-shape';
|
|
4
|
-
export { DEFAULT_DEFINITION, DEFAULT_BRANCH_LEVEL, DEFAULT_FRUIT, DEFAULT_FRUIT_AMOUNT, DEFAULT_FRUIT_COLOR } from './defaults';
|
|
4
|
+
export { DEFAULT_DEFINITION, DEFAULT_BRANCH_LEVEL, DEFAULT_FRUIT, DEFAULT_GROUND_TINT, DEFAULT_OCCLUSION, DEFAULT_ROOTS, DEFAULT_TRANSLUCENCY, DEFAULT_FRUIT_AMOUNT, DEFAULT_FRUIT_COLOR } from './defaults';
|
|
5
5
|
export { parseDefinition, extendDefinition, fetchDefinition, TreeDefinitionError, type DefinitionPatch, } from './parse';
|
|
6
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/definition/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,WAAW,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACzG,YAAY,EACV,cAAc,EACd,mBAAmB,EACnB,WAAW,EACX,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,eAAe,EACf,qBAAqB,EACrB,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,gBAAgB,EAChB,SAAS,EACT,eAAe,EACf,OAAO,EACP,mBAAmB,EACnB,sBAAsB,EACtB,sBAAsB,EACtB,QAAQ,EACR,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,MAAM,EACN,YAAY,EACZ,UAAU,EACV,YAAY,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,aAAa,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/definition/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,sBAAsB,EAAE,WAAW,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AACzG,YAAY,EACV,cAAc,EACd,mBAAmB,EACnB,WAAW,EACX,QAAQ,EACR,SAAS,EACT,QAAQ,EACR,eAAe,EACf,qBAAqB,EACrB,SAAS,EACT,QAAQ,EACR,QAAQ,EACR,gBAAgB,EAChB,SAAS,EACT,eAAe,EACf,eAAe,EACf,OAAO,EACP,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,sBAAsB,EACtB,gBAAgB,EAChB,sBAAsB,EACtB,mBAAmB,EACnB,QAAQ,EACR,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,MAAM,EACN,YAAY,EACZ,UAAU,EACV,YAAY,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,aAAa,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,aAAa,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAC7M,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,eAAe,EACf,mBAAmB,EACnB,KAAK,eAAe,GACrB,MAAM,SAAS,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/definition/schema.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/definition/schema.ts"],"names":[],"mappings":"AASA,OAAO,EAsBL,KAAK,cAAc,EAEpB,MAAM,SAAS,CAAC;AAEjB,6GAA6G;AAC7G,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;gBACX,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAK3C;AAYD,wBAAgB,QAAQ,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEjE;AAuOD;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,cAAc,CAE/E"}
|