@kerf-js/keel 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +16 -0
- package/README.md +306 -2
- package/package.json +59 -3
- package/src/blend-inset.ts +79 -0
- package/src/blend.ts +120 -0
- package/src/client.d.ts +9 -0
- package/src/generate/bust.ts +24 -0
- package/src/generate/bust.worker.ts +4 -0
- package/src/generate/pack.ts +69 -0
- package/src/generate/plate.ts +51 -0
- package/src/generate/plate.worker.ts +4 -0
- package/src/generate/serve.ts +56 -0
- package/src/generate/surface.ts +16 -0
- package/src/generate/surface.worker.ts +4 -0
- package/src/generate.ts +133 -0
- package/src/governor.ts +87 -0
- package/src/index.d.ts +15 -0
- package/src/index.mjs +63 -0
- package/src/lit.d.ts +384 -0
- package/src/paint-live.ts +60 -0
- package/src/paint-recipe.d.mts +29 -0
- package/src/paint-recipe.mjs +29 -0
- package/src/paint-worker.mjs +20 -0
- package/src/paint.d.mts +37 -0
- package/src/paint.mjs +180 -0
- package/src/runtime.ts +35 -0
- package/src/scene.ts +289 -0
- package/src/stage.ts +192 -0
- package/vendor/LICENSE +21 -0
- package/vendor/LICENSE-modules +21 -0
- package/vendor/NOTICE +24 -0
- package/vendor/README.md +13 -0
- package/vendor/lit.d.mts +1 -0
- package/vendor/lit.mjs +2 -0
- package/vendor/lock.json +177 -0
- package/vendor/modules/band/events.d.ts +20 -0
- package/vendor/modules/band/index.d.ts +29 -0
- package/vendor/modules/band/player.d.ts +43 -0
- package/vendor/modules/band/roll.d.ts +14 -0
- package/vendor/modules/band/score.d.ts +45 -0
- package/vendor/modules/band/styles.data.d.ts +37 -0
- package/vendor/modules/band/voices.d.ts +33 -0
- package/vendor/modules/band.d.mts +1 -0
- package/vendor/modules/band.mjs +2 -0
- package/vendor/modules/butterflies/butterflies.glsl.d.ts +2 -0
- package/vendor/modules/butterflies/flight.d.ts +68 -0
- package/vendor/modules/butterflies/index.d.ts +79 -0
- package/vendor/modules/butterflies/wing.d.ts +38 -0
- package/vendor/modules/butterflies.d.mts +1 -0
- package/vendor/modules/butterflies.inputs.json +73 -0
- package/vendor/modules/butterflies.mjs +39 -0
- package/vendor/modules/camera-rail/index.d.ts +113 -0
- package/vendor/modules/camera-rail.d.mts +1 -0
- package/vendor/modules/camera-rail.mjs +2 -0
- package/vendor/modules/device-profile/index.d.ts +47 -0
- package/vendor/modules/device-profile.d.mts +1 -0
- package/vendor/modules/device-profile.mjs +2 -0
- package/vendor/modules/lit-finish/dress.d.ts +34 -0
- package/vendor/modules/lit-finish/finish.glsl.d.ts +15 -0
- package/vendor/modules/lit-finish/index.d.ts +33 -0
- package/vendor/modules/lit-finish/lit.d.ts +52 -0
- package/vendor/modules/lit-finish/pass.d.ts +35 -0
- package/vendor/modules/lit-finish/settings.d.ts +88 -0
- package/vendor/modules/lit-finish.d.mts +1 -0
- package/vendor/modules/lit-finish.inputs.json +200 -0
- package/vendor/modules/lit-finish.mjs +267 -0
- package/vendor/modules/look/index.d.ts +159 -0
- package/vendor/modules/look.d.mts +1 -0
- package/vendor/modules/look.inputs.json +23 -0
- package/vendor/modules/look.mjs +2 -0
- package/vendor/modules/motes/index.d.ts +83 -0
- package/vendor/modules/motes/motes.glsl.d.ts +9 -0
- package/vendor/modules/motes/place.d.ts +59 -0
- package/vendor/modules/motes.d.mts +1 -0
- package/vendor/modules/motes.inputs.json +116 -0
- package/vendor/modules/motes.mjs +68 -0
- package/vendor/modules/plate-painter/dab.d.ts +44 -0
- package/vendor/modules/plate-painter/exact.d.ts +19 -0
- package/vendor/modules/plate-painter/foliage.d.ts +4 -0
- package/vendor/modules/plate-painter/gpu.d.ts +65 -0
- package/vendor/modules/plate-painter/index.d.ts +14 -0
- package/vendor/modules/plate-painter/paint.glsl.d.ts +14 -0
- package/vendor/modules/plate-painter/plan.d.ts +42 -0
- package/vendor/modules/plate-painter/recipe.d.ts +136 -0
- package/vendor/modules/plate-painter/scene.d.ts +4 -0
- package/vendor/modules/plate-painter.d.mts +1 -0
- package/vendor/modules/plate-painter.inputs.json +50 -0
- package/vendor/modules/plate-painter.mjs +384 -0
- package/vendor/modules/portrait/body.d.ts +25 -0
- package/vendor/modules/portrait/bust.d.ts +67 -0
- package/vendor/modules/portrait/cap.d.ts +12 -0
- package/vendor/modules/portrait/compile.d.ts +8 -0
- package/vendor/modules/portrait/exact.d.ts +17 -0
- package/vendor/modules/portrait/hair.d.ts +26 -0
- package/vendor/modules/portrait/hand.d.ts +30 -0
- package/vendor/modules/portrait/head.d.ts +18 -0
- package/vendor/modules/portrait/index.d.ts +12 -0
- package/vendor/modules/portrait/mesh.d.ts +24 -0
- package/vendor/modules/portrait/parts.d.ts +33 -0
- package/vendor/modules/portrait/portrait.glsl.d.ts +4 -0
- package/vendor/modules/portrait/render.d.ts +125 -0
- package/vendor/modules/portrait/sdf.d.ts +75 -0
- package/vendor/modules/portrait/settings.d.ts +27 -0
- package/vendor/modules/portrait.d.mts +1 -0
- package/vendor/modules/portrait.inputs.json +111 -0
- package/vendor/modules/portrait.mjs +2 -0
- package/vendor/modules/quality/index.d.ts +130 -0
- package/vendor/modules/quality.d.mts +1 -0
- package/vendor/modules/quality.inputs.json +34 -0
- package/vendor/modules/quality.mjs +2 -0
- package/vendor/modules/scene-blend/blend.d.ts +54 -0
- package/vendor/modules/scene-blend/blend.glsl.d.ts +8 -0
- package/vendor/modules/scene-blend/index.d.ts +25 -0
- package/vendor/modules/scene-blend/lit.d.ts +61 -0
- package/vendor/modules/scene-blend/noise.d.ts +13 -0
- package/vendor/modules/scene-blend/settings.d.ts +63 -0
- package/vendor/modules/scene-blend.d.mts +1 -0
- package/vendor/modules/scene-blend.inputs.json +133 -0
- package/vendor/modules/scene-blend.mjs +2 -0
- package/vendor/modules/section-post/index.d.ts +23 -0
- package/vendor/modules/section-post/lit.d.ts +47 -0
- package/vendor/modules/section-post/noise.d.ts +14 -0
- package/vendor/modules/section-post/post.d.ts +31 -0
- package/vendor/modules/section-post/post.glsl.d.ts +8 -0
- package/vendor/modules/section-post/settings.d.ts +84 -0
- package/vendor/modules/section-post.d.mts +1 -0
- package/vendor/modules/section-post.inputs.json +107 -0
- package/vendor/modules/section-post.mjs +53 -0
- package/vendor/modules/surfaces/exact.d.ts +8 -0
- package/vendor/modules/surfaces/field.d.ts +7 -0
- package/vendor/modules/surfaces/gpu.d.ts +19 -0
- package/vendor/modules/surfaces/index.d.ts +17 -0
- package/vendor/modules/surfaces/paint.d.ts +28 -0
- package/vendor/modules/surfaces/plan.d.ts +39 -0
- package/vendor/modules/surfaces/print.d.ts +55 -0
- package/vendor/modules/surfaces/recipe.d.ts +143 -0
- package/vendor/modules/surfaces/surface.glsl.d.ts +4 -0
- package/vendor/modules/surfaces.d.mts +1 -0
- package/vendor/modules/surfaces.inputs.json +54 -0
- package/vendor/modules/surfaces.mjs +172 -0
- package/vendor/modules/tracks/index.d.ts +66 -0
- package/vendor/modules/tracks.d.mts +1 -0
- package/vendor/modules/tracks.mjs +2 -0
- package/vendor/modules/tree-growth/bend.d.ts +28 -0
- package/vendor/modules/tree-growth/frame.d.ts +60 -0
- package/vendor/modules/tree-growth/index.d.ts +23 -0
- package/vendor/modules/tree-growth/light.d.ts +13 -0
- package/vendor/modules/tree-growth/math.d.ts +19 -0
- package/vendor/modules/tree-growth/model.d.ts +100 -0
- package/vendor/modules/tree-growth/sectors.d.ts +10 -0
- package/vendor/modules/tree-growth/simulation.d.ts +58 -0
- package/vendor/modules/tree-growth/species.d.ts +117 -0
- package/vendor/modules/tree-growth/species.data.d.ts +2 -0
- package/vendor/modules/tree-growth/year.d.ts +38 -0
- package/vendor/modules/tree-growth.d.mts +1 -0
- package/vendor/modules/tree-growth.inputs.json +75 -0
- package/vendor/modules/tree-growth.mjs +2 -0
- package/vendor/modules/tree-render/features.d.ts +9 -0
- package/vendor/modules/tree-render/forest/bake.d.ts +41 -0
- package/vendor/modules/tree-render/forest/cards.d.ts +28 -0
- package/vendor/modules/tree-render/forest/forest.d.ts +156 -0
- package/vendor/modules/tree-render/index.d.ts +52 -0
- package/vendor/modules/tree-render/inputs.d.ts +260 -0
- package/vendor/modules/tree-render/instances.d.ts +66 -0
- package/vendor/modules/tree-render/math.d.ts +8 -0
- package/vendor/modules/tree-render/tree/bark.d.ts +20 -0
- package/vendor/modules/tree-render/tree/leaves.d.ts +29 -0
- package/vendor/modules/tree-render/tree/litter.d.ts +21 -0
- package/vendor/modules/tree-render/tree/ornaments.d.ts +36 -0
- package/vendor/modules/tree-render/tree/roots.d.ts +75 -0
- package/vendor/modules/tree-render/tree/shapes.d.ts +49 -0
- package/vendor/modules/tree-render/tree/tree.d.ts +239 -0
- package/vendor/modules/tree-render/tree/wood.d.ts +27 -0
- package/vendor/modules/tree-render/wind.d.ts +51 -0
- package/vendor/modules/tree-render.d.mts +1 -0
- package/vendor/modules/tree-render.inputs.json +45 -0
- package/vendor/modules/tree-render.mjs +2 -0
- package/vendor/modules/voxel-dither/dither.glsl.d.ts +9 -0
- package/vendor/modules/voxel-dither/index.d.ts +35 -0
- package/vendor/modules/voxel-dither/light.d.ts +33 -0
- package/vendor/modules/voxel-dither/lit.d.ts +86 -0
- package/vendor/modules/voxel-dither/pass.d.ts +46 -0
- package/vendor/modules/voxel-dither/screens.d.ts +21 -0
- package/vendor/modules/voxel-dither/settings.d.ts +307 -0
- package/vendor/modules/voxel-dither/signals.d.ts +35 -0
- package/vendor/modules/voxel-dither.d.mts +1 -0
- package/vendor/modules/voxel-dither.inputs.json +295 -0
- package/vendor/modules/voxel-dither.mjs +452 -0
- package/vendor/modules/world-light/index.d.ts +133 -0
- package/vendor/modules/world-light.d.mts +1 -0
- package/vendor/modules/world-light.inputs.json +68 -0
- package/vendor/modules/world-light.mjs +2 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { InstancedLike, SlotsLike, TreeFrameLike, YearLike } from "../inputs.js";
|
|
2
|
+
import type { OrnamentSet, Tick, Tree, TreeMotion } from "./tree.js";
|
|
3
|
+
/** Which slot of which set fell, and how far its kind scatters (fruit drops close; leaves and petals blow about). */
|
|
4
|
+
export interface Fallen {
|
|
5
|
+
readonly slots: SlotsLike;
|
|
6
|
+
readonly index: number;
|
|
7
|
+
readonly scale: number;
|
|
8
|
+
}
|
|
9
|
+
/** Where a fallen leaf from `index` lies: under its twig, scattered by the drop, kept on the ground. */
|
|
10
|
+
export declare function litterSpot(tree: Tree, frame: TreeFrameLike, fallen: Fallen): {
|
|
11
|
+
x: number;
|
|
12
|
+
z: number;
|
|
13
|
+
};
|
|
14
|
+
export declare function ornamentsLying(set: OrnamentSet, year: YearLike, motion: TreeMotion): boolean;
|
|
15
|
+
export declare function soundBearer(set: OrnamentSet, frame: TreeFrameLike, index: number): boolean;
|
|
16
|
+
export declare function poseLitter(tree: Tree, tick: Tick): void;
|
|
17
|
+
export declare function paintLitter(tree: Tree, year: YearLike): void;
|
|
18
|
+
/** Snow settles in a thin slab along the top of every limb that is not too steep, sloping as the limb does. */
|
|
19
|
+
export declare function poseSnow(tree: Tree, mesh: InstancedLike, frame: TreeFrameLike, motion: TreeMotion): void;
|
|
20
|
+
export declare function spawnFallers(tree: Tree, frame: TreeFrameLike, year: YearLike, motion: TreeMotion): void;
|
|
21
|
+
export declare function drawFallers(tree: Tree, falling: InstancedLike, fallingLeaves: InstancedLike, motion: TreeMotion): void;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { ColorLike, GeometryLike, TreeKindOrnaments, YearLike } from "../inputs.js";
|
|
2
|
+
import type { OrnamentSet, Tick, Tree, TreeFruit, TreeMotion } from "./tree.js";
|
|
3
|
+
import type { V3 } from "../instances.js";
|
|
4
|
+
type SetHost = Pick<Tree, "lit" | "group" | "model" | "features" | "smooth">;
|
|
5
|
+
/** What a set draws as: its shape, and the spray shape a blossom set may take instead (the `sprays` look). */
|
|
6
|
+
export interface SetShape {
|
|
7
|
+
readonly shape: GeometryLike;
|
|
8
|
+
readonly spray?: GeometryLike | null;
|
|
9
|
+
}
|
|
10
|
+
/** The tree's own set also owns a run of slots in the litter mesh. */
|
|
11
|
+
export interface SetLitter extends SetShape {
|
|
12
|
+
readonly litterStart: number;
|
|
13
|
+
readonly litterLimit: number;
|
|
14
|
+
}
|
|
15
|
+
export declare function ornamentSet(tree: SetHost, name: OrnamentSet["name"], draw: SetLitter): OrnamentSet | null;
|
|
16
|
+
/** A minor kind's flowers or fruit as a set of their own (no litter: they fall with the tree's own). */
|
|
17
|
+
export declare function kindSet(tree: SetHost, kind: TreeKindOrnaments, name: OrnamentSet["name"], draw: SetShape): OrnamentSet | null;
|
|
18
|
+
/** The year a set keeps: a minor kind's own calendar, else the tree's. */
|
|
19
|
+
export declare const kindYear: (tree: Tree, set: OrnamentSet, year: YearLike) => YearLike;
|
|
20
|
+
export declare const eatenSlot: (tree: Tree, set: OrnamentSet, index: number) => boolean;
|
|
21
|
+
/** A new crop starts clean: once a set has no fruit open, last year's eaten slots are forgotten. */
|
|
22
|
+
export declare function forgetEaten(tree: Tree, year: YearLike): void;
|
|
23
|
+
export declare function ripeFruit(tree: Tree): TreeFruit[];
|
|
24
|
+
export declare function eatFruit(tree: Tree, key: string): boolean;
|
|
25
|
+
/** The air a pass poses in: the frame's motion, the wind the sway field uses and the tree's height. */
|
|
26
|
+
export interface Air {
|
|
27
|
+
readonly motion: TreeMotion;
|
|
28
|
+
readonly wind: number;
|
|
29
|
+
readonly height: number;
|
|
30
|
+
}
|
|
31
|
+
/** The sway field's offset into `tree.offset`, or none when the host moves the tree itself. */
|
|
32
|
+
export declare function stillOrSway(tree: Tree, p: V3, air: Air, wind?: number): void;
|
|
33
|
+
export declare function poseOrnaments(tree: Tree, set: OrnamentSet, tick: Tick): void;
|
|
34
|
+
export declare function ornamentColor(tree: Tree, set: OrnamentSet, index: number, year: YearLike): ColorLike;
|
|
35
|
+
export declare function paintOrnaments(tree: Tree, set: OrnamentSet, year: YearLike): void;
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { TreeGround } from "../inputs.js";
|
|
2
|
+
export declare const ROOT_SEGMENTS = 18;
|
|
3
|
+
export interface RootPoint {
|
|
4
|
+
readonly x: number;
|
|
5
|
+
readonly y: number;
|
|
6
|
+
readonly z: number;
|
|
7
|
+
readonly radius: number;
|
|
8
|
+
readonly gone: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* How one root of an old tree breaks its planter (`rootBreak`). `heave` (0 to 1)
|
|
12
|
+
* grows with the trunk: the root arches higher out of the soil and levers the
|
|
13
|
+
* rim up where it rolls over. `burst` is how far down the wall, as a share of
|
|
14
|
+
* its depth, the root punches out through the side instead (0: over the lip);
|
|
15
|
+
* `hang` is how far below the wall's foot it may then dangle.
|
|
16
|
+
*/
|
|
17
|
+
export interface RootBreak {
|
|
18
|
+
readonly heave: number;
|
|
19
|
+
readonly burst: number;
|
|
20
|
+
readonly hang: number;
|
|
21
|
+
}
|
|
22
|
+
export declare const NO_ROOT_BREAK: RootBreak;
|
|
23
|
+
/**
|
|
24
|
+
* Plans every root's break for a tree of this trunk on this ground, seeded:
|
|
25
|
+
* an old tree's roots all heave; on a planter whose side they can break (not
|
|
26
|
+
* metal or gems, see `TreeGround.planter.hard`) most old trees, not all, send
|
|
27
|
+
* a root or two out through the wall, the longest first.
|
|
28
|
+
*/
|
|
29
|
+
export declare function rootBreaks(roots: readonly {
|
|
30
|
+
readonly angle: number;
|
|
31
|
+
readonly reach: number;
|
|
32
|
+
}[], trunk: number, ground: TreeGround, seed?: number): RootBreak[];
|
|
33
|
+
/**
|
|
34
|
+
* A surface root as ROOT_SEGMENTS + 1 points. It wanders out from the trunk
|
|
35
|
+
* foot, diving under the turf and surfacing again, and on a planter an old
|
|
36
|
+
* tree's longest roots roll over the lip and creep down the wall. Length grows
|
|
37
|
+
* with the trunk, so saplings keep theirs short. A `rootBreaks` plan heaves an
|
|
38
|
+
* old root higher, or sends it out through the planter's side.
|
|
39
|
+
*/
|
|
40
|
+
export declare function rootPath(root: {
|
|
41
|
+
readonly angle: number;
|
|
42
|
+
readonly reach: number;
|
|
43
|
+
}, trunk: number, ground: TreeGround, plan?: RootBreak): RootPoint[];
|
|
44
|
+
/** A chunk of planter an old root broke loose. */
|
|
45
|
+
export interface RootShard {
|
|
46
|
+
readonly x: number;
|
|
47
|
+
readonly y: number;
|
|
48
|
+
readonly z: number;
|
|
49
|
+
readonly size: readonly [number, number, number];
|
|
50
|
+
readonly angle: number;
|
|
51
|
+
readonly tilt: number;
|
|
52
|
+
readonly roll: number;
|
|
53
|
+
readonly tone: number;
|
|
54
|
+
}
|
|
55
|
+
/** The most chunks one root breaks off; the shard mesh is this times the root count, fixed. */
|
|
56
|
+
export declare const ROOT_SHARDS = 8;
|
|
57
|
+
/** A shard tone past the planter's colours: the dark of a hole or crack in its wall. */
|
|
58
|
+
export declare const HOLE_TONE = 3;
|
|
59
|
+
/**
|
|
60
|
+
* The chunks one root breaks out of its planter, seeded: where it rolls over
|
|
61
|
+
* the lip, two rim pieces levered up either side of it (a hard planter just
|
|
62
|
+
* cracks: smaller pieces); where it bursts through the side, a ring of broken
|
|
63
|
+
* wall round the hole, one fallen lower, and the rim above split.
|
|
64
|
+
*/
|
|
65
|
+
/** What a root breaks: the trunk it grows from, the ground it breaks, its plan, and the tree's seed (1). */
|
|
66
|
+
export interface Breakage {
|
|
67
|
+
readonly trunk: number;
|
|
68
|
+
readonly ground: TreeGround;
|
|
69
|
+
readonly plan: RootBreak;
|
|
70
|
+
readonly seed?: number;
|
|
71
|
+
}
|
|
72
|
+
export declare function rootShards(root: {
|
|
73
|
+
readonly angle: number;
|
|
74
|
+
readonly reach: number;
|
|
75
|
+
}, index: number, breakage: Breakage): RootShard[];
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { GeometryLike, LitLike } from "../inputs.js";
|
|
2
|
+
/** A slim pointed leaf, stalk at the origin and tip up +Y, as [half-width, height] pairs. */
|
|
3
|
+
export declare const LEAF_OUTLINE: readonly (readonly [number, number])[];
|
|
4
|
+
/**
|
|
5
|
+
* A leaf blade folded along a pale midrib with darker margins, so even a few
|
|
6
|
+
* pixels read as a leaf and not a dot. Colours are baked as vertex colours.
|
|
7
|
+
*/
|
|
8
|
+
export declare function bladeGeometry(lit: LitLike, outline?: readonly (readonly [number, number])[], fold?: number, bend?: number): GeometryLike;
|
|
9
|
+
/** The broad leaf blade with a soft margin (the `clumps` look). */
|
|
10
|
+
export declare function softBladeGeometry(lit: LitLike): GeometryLike;
|
|
11
|
+
export interface TreeShapes {
|
|
12
|
+
readonly wood: GeometryLike;
|
|
13
|
+
readonly leaf: GeometryLike;
|
|
14
|
+
readonly blade: GeometryLike;
|
|
15
|
+
readonly bud: GeometryLike;
|
|
16
|
+
readonly box: GeometryLike;
|
|
17
|
+
/** The broad blade with a soft margin (the `clumps` look). */
|
|
18
|
+
readonly softBlade: GeometryLike;
|
|
19
|
+
/** A blossom spray: a few round flower heads in a puff, lit on top and rose in its own shade (the `sprays` look). */
|
|
20
|
+
readonly spray: GeometryLike;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* A spray of blossom as one shape: a few flower heads bunched round the twig.
|
|
24
|
+
* Vertex colours carry two tones so the spray reads at a few pixels: the tops
|
|
25
|
+
* of the heads catch the light near white, the undersides sink to a deeper,
|
|
26
|
+
* rosier shade of the petal colour (red holds, green and blue drop).
|
|
27
|
+
*/
|
|
28
|
+
export declare function sprayGeometry(lit: LitLike): GeometryLike;
|
|
29
|
+
/** A conifer's needle sprig. */
|
|
30
|
+
export type NeedleKind = "pine" | "spruce" | "redwood";
|
|
31
|
+
/**
|
|
32
|
+
* A conifer sprig for the forest: the same shoot and the same sweep of needles,
|
|
33
|
+
* each one flat and wider, so `count` of them hold the sprig's mass for a tenth
|
|
34
|
+
* of its triangles.
|
|
35
|
+
*/
|
|
36
|
+
export declare function lightSprig(lit: LitLike, kind: string, count: number): GeometryLike;
|
|
37
|
+
/** The needles of one conifer sprig. */
|
|
38
|
+
export declare function needleGeometry(lit: LitLike, kind: NeedleKind): GeometryLike;
|
|
39
|
+
export declare const NEEDLE_KINDS: Readonly<Record<string, NeedleKind>>;
|
|
40
|
+
/** A palm leaflet: a long narrow strap, slim at its base, tapering to a point. */
|
|
41
|
+
export declare const PALM_LEAFLET: readonly (readonly [number, number])[];
|
|
42
|
+
/**
|
|
43
|
+
* The blade a species grows: needles for the conifers, arched straps for a palm, the broad leaf for everything else.
|
|
44
|
+
*/
|
|
45
|
+
export declare function speciesBlade(lit: LitLike, speciesId: string): GeometryLike;
|
|
46
|
+
/**
|
|
47
|
+
* The shared shapes, made once per keel/lit namespace: round wood, low-poly leaf lumps, blades, buds and a unit box.
|
|
48
|
+
*/
|
|
49
|
+
export declare function treeShapes(lit: LitLike): TreeShapes;
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import type { ColorLike, GeometryLike, InstancedLike, LitLike, NodeLike, OrnamentSpecLike, SlotsLike, TreeBloom, TreeColors, TreeFrameLike, TreeGround, TreeKindOrnaments, TreeModelLike, TreeSkin, TreeStrain, YearLike } from "../inputs.js";
|
|
2
|
+
import type { TreeFeature, TreeFeatures } from "../features.js";
|
|
3
|
+
import type { Offset } from "../wind.js";
|
|
4
|
+
import type { TreeShapes } from "./shapes.js";
|
|
5
|
+
import type { OrnamentLook } from "./bark.js";
|
|
6
|
+
import type { RootBreak } from "./roots.js";
|
|
7
|
+
import type { FrondLayout } from "./leaves.js";
|
|
8
|
+
export interface TreeLimits {
|
|
9
|
+
readonly litter?: number;
|
|
10
|
+
readonly flowerLitter?: number;
|
|
11
|
+
readonly fruitLitter?: number;
|
|
12
|
+
readonly falling?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface TreeRenderOptions {
|
|
15
|
+
readonly colors: TreeColors;
|
|
16
|
+
readonly ground?: TreeGround;
|
|
17
|
+
readonly features?: Partial<Record<TreeFeature, boolean>> | string;
|
|
18
|
+
/** "smooth" draws round wood and leaf blades; "voxel" draws everything as blocks. */
|
|
19
|
+
readonly form?: "smooth" | "voxel";
|
|
20
|
+
/** Swap a shape (a skin's crystal leaves, coin leaves). Blades are any shape with vertex colours. */
|
|
21
|
+
readonly shapes?: Partial<Pick<TreeShapes, "wood" | "leaf" | "blade" | "bud">>;
|
|
22
|
+
readonly skin?: TreeSkin | null;
|
|
23
|
+
readonly limits?: TreeLimits;
|
|
24
|
+
readonly seed?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Strains of a hybrid or chimera, by number; strain 0 is the tree's own colours and skin, so `strains[0]` is not
|
|
27
|
+
* read.
|
|
28
|
+
*/
|
|
29
|
+
readonly strains?: readonly TreeStrain[];
|
|
30
|
+
/** Each internode's strain (tree-growth's `sectors`); its leaves, flowers, fruit and bark take that strain's look. */
|
|
31
|
+
readonly strainOf?: ArrayLike<number>;
|
|
32
|
+
/**
|
|
33
|
+
* A mixed bloom: each blossom opens in one of these colours, by share (codominant flower colour). Left out, blossoms
|
|
34
|
+
* take the strain's spring colours.
|
|
35
|
+
*/
|
|
36
|
+
readonly blooms?: readonly TreeBloom[];
|
|
37
|
+
/** Minor kinds' own flowers and fruit: cherry limbs on an oak blossom though the oak only hangs catkins. */
|
|
38
|
+
readonly kinds?: readonly TreeKindOrnaments[];
|
|
39
|
+
}
|
|
40
|
+
/** What moves the tree this frame. `snow` 0..1 lies along the limbs; `snowed` hides litter under fresh snow. */
|
|
41
|
+
export interface TreeMotion {
|
|
42
|
+
readonly elapsed: number;
|
|
43
|
+
readonly delta?: number;
|
|
44
|
+
readonly wind: number;
|
|
45
|
+
/** The way the wind blows toward, in radians from +x toward +z (see `breezeAt`). */
|
|
46
|
+
readonly windDir?: number;
|
|
47
|
+
readonly dead?: boolean;
|
|
48
|
+
readonly snow?: number;
|
|
49
|
+
readonly snowed?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* How much the built-in sway field moves the wood, leaves and fruit (1, the
|
|
52
|
+
* default). A host that moves the tree itself (keel/tree-mechanics) passes 0:
|
|
53
|
+
* leaves still flutter and hanging fruit still swings on its stalk.
|
|
54
|
+
*/
|
|
55
|
+
readonly field?: number;
|
|
56
|
+
/**
|
|
57
|
+
* Each strain's own year (tree-growth `yearState` for its species), so its
|
|
58
|
+
* limbs leaf out, blossom and turn on their own calendar: an oak limb on a
|
|
59
|
+
* cherry is still in bud while the cherry blooms. Strain 0, and any left
|
|
60
|
+
* out, follow the tree's year.
|
|
61
|
+
*/
|
|
62
|
+
readonly strainYears?: readonly (YearLike | undefined)[];
|
|
63
|
+
}
|
|
64
|
+
/** One frame's input: the grown frame, the year and what moves the tree. */
|
|
65
|
+
export interface Tick {
|
|
66
|
+
readonly frame: TreeFrameLike;
|
|
67
|
+
readonly year: YearLike;
|
|
68
|
+
readonly motion: TreeMotion;
|
|
69
|
+
}
|
|
70
|
+
export interface TreeMeshes {
|
|
71
|
+
readonly wood: InstancedLike;
|
|
72
|
+
readonly leaves: InstancedLike | null;
|
|
73
|
+
readonly flowers: InstancedLike | null;
|
|
74
|
+
readonly fruit: InstancedLike | null;
|
|
75
|
+
readonly leafLitter: InstancedLike | null;
|
|
76
|
+
readonly litter: InstancedLike | null;
|
|
77
|
+
readonly snow: InstancedLike | null;
|
|
78
|
+
readonly falling: InstancedLike | null;
|
|
79
|
+
readonly fallingLeaves: InstancedLike | null;
|
|
80
|
+
/** Chunks of planter an old tree's roots broke loose (`rootBreak`, smooth form, on a planter). */
|
|
81
|
+
readonly shards: InstancedLike | null;
|
|
82
|
+
}
|
|
83
|
+
export interface TreeRender {
|
|
84
|
+
/** Add this to the scene once. */
|
|
85
|
+
readonly group: unknown;
|
|
86
|
+
readonly features: TreeFeatures;
|
|
87
|
+
/** The instanced meshes, for a host that swaps materials (skins) or adds effects (night glow). Off parts are null. */
|
|
88
|
+
readonly meshes: TreeMeshes;
|
|
89
|
+
/** Minor kinds' own flowers and fruit, one mesh per set (see `TreeRenderOptions.kinds`). */
|
|
90
|
+
readonly kinds: readonly InstancedLike[];
|
|
91
|
+
/** Pose and, when the season or frame changed, repaint. Call every frame. */
|
|
92
|
+
update(frame: TreeFrameLike, year: YearLike, motion: TreeMotion): void;
|
|
93
|
+
/** Leaves, petals and fruit falling or lying where they landed, for a host's own drawing (a canvas fallback). */
|
|
94
|
+
readonly fallers: readonly Readonly<Pick<Faller, "x" | "y" | "z" | "size" | "color" | "landed" | "kind">>[];
|
|
95
|
+
/** The ripe fruit as of the last update, hanging on the tree or lying under it, for animals to eat. */
|
|
96
|
+
fruit(): TreeFruit[];
|
|
97
|
+
/**
|
|
98
|
+
* Take a fruit (by its `TreeFruit.key`) off the tree or the ground until next year's crop. False when there was none.
|
|
99
|
+
*/
|
|
100
|
+
eat(key: string): boolean;
|
|
101
|
+
/** Repaint on the next update (after a material swap, say). */
|
|
102
|
+
repaint(): void;
|
|
103
|
+
dispose(): void;
|
|
104
|
+
}
|
|
105
|
+
/** A ripe fruit, where it hangs or lies. Its `key` holds while it ripens, falls and lies. */
|
|
106
|
+
export interface TreeFruit {
|
|
107
|
+
readonly key: string;
|
|
108
|
+
/** The ornament kind: "apple", "acorn", "cherry" and so on. */
|
|
109
|
+
readonly kind: string;
|
|
110
|
+
readonly x: number;
|
|
111
|
+
readonly y: number;
|
|
112
|
+
readonly z: number;
|
|
113
|
+
/** Its size across, in scene units. */
|
|
114
|
+
readonly size: number;
|
|
115
|
+
/** On the tree (true) or on the ground under it. */
|
|
116
|
+
readonly hanging: boolean;
|
|
117
|
+
}
|
|
118
|
+
export interface OrnamentSet {
|
|
119
|
+
readonly name: "flowers" | "fruit";
|
|
120
|
+
/** A minor kind's set opens on this strain's year and ignores the tree's own bearing rules; -1 is the tree's own. */
|
|
121
|
+
readonly strain: number;
|
|
122
|
+
readonly spec: OrnamentSpecLike;
|
|
123
|
+
readonly look: OrnamentLook;
|
|
124
|
+
readonly slots: SlotsLike;
|
|
125
|
+
readonly mesh: InstancedLike;
|
|
126
|
+
readonly litterStart: number;
|
|
127
|
+
readonly litterLimit: number;
|
|
128
|
+
readonly stride: number;
|
|
129
|
+
/** Drawn as sprays (the `sprays` look): every `thin`th slot draws, `grow` times its size, one tone per twig. */
|
|
130
|
+
readonly spray: boolean;
|
|
131
|
+
readonly thin: number;
|
|
132
|
+
readonly grow: number;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* How a blossom set draws as sprays: a big crown keeps every other slot at twice the size (fewer, readable sprays); a
|
|
136
|
+
* small one keeps all.
|
|
137
|
+
*/
|
|
138
|
+
export declare function sprayPlan(tree: Pick<Tree, "features" | "smooth">, spec: OrnamentSpecLike, slots: SlotsLike, own: boolean): {
|
|
139
|
+
spray: boolean;
|
|
140
|
+
thin: number;
|
|
141
|
+
grow: number;
|
|
142
|
+
};
|
|
143
|
+
export interface Faller {
|
|
144
|
+
readonly key: string;
|
|
145
|
+
readonly kind: "leaf" | "flowers" | "fruit";
|
|
146
|
+
x: number;
|
|
147
|
+
y: number;
|
|
148
|
+
z: number;
|
|
149
|
+
vx: number;
|
|
150
|
+
vz: number;
|
|
151
|
+
readonly phase: number;
|
|
152
|
+
readonly size: readonly [number, number, number];
|
|
153
|
+
readonly color: string;
|
|
154
|
+
readonly speed: number;
|
|
155
|
+
landed: boolean;
|
|
156
|
+
}
|
|
157
|
+
export interface Tree {
|
|
158
|
+
readonly lit: LitLike;
|
|
159
|
+
readonly model: TreeModelLike;
|
|
160
|
+
readonly colors: TreeColors;
|
|
161
|
+
readonly ground: TreeGround;
|
|
162
|
+
readonly features: TreeFeatures;
|
|
163
|
+
readonly smooth: boolean;
|
|
164
|
+
readonly blades: boolean;
|
|
165
|
+
/** Conifer needles: each sprig lies along its twig, stiff, instead of hanging off it like a leaf. */
|
|
166
|
+
readonly needles: boolean;
|
|
167
|
+
/** A palm's leaflets, laid out in two rows down each frond. */
|
|
168
|
+
readonly fronds: FrondLayout | null;
|
|
169
|
+
readonly skin: TreeSkin | null;
|
|
170
|
+
readonly strains: readonly TreeStrain[];
|
|
171
|
+
readonly strainOf: ArrayLike<number> | null;
|
|
172
|
+
readonly blooms: readonly TreeBloom[];
|
|
173
|
+
strainYears: readonly (YearLike | undefined)[];
|
|
174
|
+
readonly group: NodeLike;
|
|
175
|
+
readonly meshes: TreeMeshes;
|
|
176
|
+
readonly flowers: OrnamentSet | null;
|
|
177
|
+
readonly fruits: OrnamentSet | null;
|
|
178
|
+
readonly kinds: readonly OrnamentSet[];
|
|
179
|
+
readonly limits: Required<TreeLimits>;
|
|
180
|
+
readonly leafStride: number;
|
|
181
|
+
readonly hidden: Map<string, {
|
|
182
|
+
readonly rank: number;
|
|
183
|
+
readonly kind: Faller["kind"];
|
|
184
|
+
readonly index: number;
|
|
185
|
+
}>;
|
|
186
|
+
/**
|
|
187
|
+
* The same slots by kind, for the per-slot test in every pose pass (a number lookup, not a string built per slot per
|
|
188
|
+
* frame).
|
|
189
|
+
*/
|
|
190
|
+
readonly hiddenSlots: Readonly<Record<Faller["kind"], Set<number>>>;
|
|
191
|
+
/** Fruit animals have eaten this year, by set ("fruit", or "kind<n>" for a minor kind's) and slot. */
|
|
192
|
+
readonly eaten: Map<string, Set<number>>;
|
|
193
|
+
lastYear: YearLike | null;
|
|
194
|
+
lastMotion: TreeMotion | null;
|
|
195
|
+
readonly fallers: Faller[];
|
|
196
|
+
readonly random: () => number;
|
|
197
|
+
readonly a: ColorLike;
|
|
198
|
+
readonly b: ColorLike;
|
|
199
|
+
readonly c: ColorLike;
|
|
200
|
+
readonly offset: Offset;
|
|
201
|
+
spawnClock: number;
|
|
202
|
+
paintKey: string;
|
|
203
|
+
lastFrame: TreeFrameLike | null;
|
|
204
|
+
/** The host moves the tree itself this frame (`field: 0`): no sway field at all. */
|
|
205
|
+
still: boolean;
|
|
206
|
+
readonly seed: number;
|
|
207
|
+
/** The roots' break plans (`rootBreak`) and the trunk radius they were made for. */
|
|
208
|
+
readonly breaks: {
|
|
209
|
+
trunk: number;
|
|
210
|
+
plans: readonly RootBreak[];
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* How a part's mesh is lit: its roughness, whether it casts shadows, and whether it is a sheet seen from both
|
|
215
|
+
* sides.
|
|
216
|
+
*/
|
|
217
|
+
export interface MeshLook {
|
|
218
|
+
readonly roughness: number;
|
|
219
|
+
readonly shadows: boolean;
|
|
220
|
+
readonly sheet?: boolean;
|
|
221
|
+
}
|
|
222
|
+
export declare function makeMesh(tree: Pick<Tree, "lit" | "group">, geometry: GeometryLike, count: number, look: MeshLook): InstancedLike;
|
|
223
|
+
export declare const ornamentState: (set: OrnamentSet, year: YearLike) => {
|
|
224
|
+
open: number;
|
|
225
|
+
fallen: number;
|
|
226
|
+
};
|
|
227
|
+
/** How far in from the tips foliage reaches: needles clothe a conifer's limbs most of the way in; other evergreens keep
|
|
228
|
+
* leaves near the tips, and everything else only at them. */
|
|
229
|
+
export declare function tipLimitOf(needles: boolean, evergreen: boolean): number;
|
|
230
|
+
export declare const leafTipLimit: (tree: Tree) => number;
|
|
231
|
+
/** Is node a living, leafy twig right now? Outer twigs carry the foliage. */
|
|
232
|
+
export declare function leafyNode(frame: TreeFrameLike, node: number, tipLimit: number): boolean;
|
|
233
|
+
/**
|
|
234
|
+
* Does this node bear a set's flowers or fruit right now? A minor kind's own set (strain 0 or more) ignores whether
|
|
235
|
+
* the node's strain bears.
|
|
236
|
+
*/
|
|
237
|
+
export declare function bearingNode(tree: Tree, frame: TreeFrameLike, set: Pick<OrnamentSet, "spec" | "strain">, node: number): boolean;
|
|
238
|
+
/** One grown tree as live instanced meshes. Build once per model; call `update` every frame. */
|
|
239
|
+
export declare function createTreeRender(lit: LitLike, model: TreeModelLike, options: TreeRenderOptions): TreeRender;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { TreeColors, TreeFrameLike, TreeSkin, TreeStrain, YearLike } from "../inputs.js";
|
|
2
|
+
import type { RootShard } from "./roots.js";
|
|
3
|
+
import type { Tree, TreeMotion } from "./tree.js";
|
|
4
|
+
export declare function poseWood(tree: Tree, frame: TreeFrameLike, motion: TreeMotion): void;
|
|
5
|
+
/** A chunk turned to face out from the planter at its angle, tipped out by `tilt` and rolled about its outward axis. */
|
|
6
|
+
export declare function writeShard(array: Float32Array, index: number, shard: RootShard): void;
|
|
7
|
+
/** The colours an internode's strain wears (the tree's own for strain 0, or when there are no strains). */
|
|
8
|
+
export declare function strainColors(tree: Tree, node: number): TreeColors;
|
|
9
|
+
/** The strain an internode belongs to, if the tree has strains. */
|
|
10
|
+
export declare const strainAt: (tree: Tree, node: number) => TreeStrain | undefined;
|
|
11
|
+
/** How far a leaf hangs below its twig on a weeping strain: strands of uneven length. */
|
|
12
|
+
export declare function strainDrop(tree: Tree, node: number, index: number): number;
|
|
13
|
+
/** Does this leaf grow as a needle sprig? The tree's own habit, unless its strain is a broadleaf kind. */
|
|
14
|
+
export declare function needleLeaf(tree: Tree, node: number): boolean;
|
|
15
|
+
/** The skin an internode's strain wears: the tree's own unless its strain sets one or drops it. */
|
|
16
|
+
export declare function strainSkin(tree: Tree, node: number): TreeSkin | null;
|
|
17
|
+
/**
|
|
18
|
+
* A stable number for the clump a twig belongs to: its parent shoot, so the
|
|
19
|
+
* leaves and flowers of neighbouring twigs share a tone and the crown reads
|
|
20
|
+
* as masses (the `clumps` and `sprays` looks), not a per-leaf speckle.
|
|
21
|
+
*/
|
|
22
|
+
export declare function clumpOf(tree: Pick<Tree, "model">, node: number): number;
|
|
23
|
+
/** The year an internode's limbs live by: its strain's own, or the tree's. */
|
|
24
|
+
export declare function strainYear(tree: Tree, node: number, year: YearLike): YearLike;
|
|
25
|
+
/** The bark colour of wood this thick: the trunk's, a limb's or a twig's. */
|
|
26
|
+
export declare function trunkTone(trunk: readonly string[], radius: number): string | undefined;
|
|
27
|
+
export declare function paintWood(tree: Tree, frame: TreeFrameLike, dead: boolean): void;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { V3 } from "./instances.js";
|
|
2
|
+
export interface Offset {
|
|
3
|
+
x: number;
|
|
4
|
+
z: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The breeze at a moment: how hard it blows (0 is dead calm), and the way it blows toward, in radians from +x toward
|
|
8
|
+
* +z.
|
|
9
|
+
*/
|
|
10
|
+
export interface Breeze {
|
|
11
|
+
readonly wind: number;
|
|
12
|
+
readonly dir: number;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A breeze that lives: it freshens and slackens over a minute or two, its
|
|
16
|
+
* direction wanders slowly about the way it prevails, and now and then
|
|
17
|
+
* (rarely) it dies away to nothing for a while. `base` is the weather's
|
|
18
|
+
* usual strength; the same seed and time always give the same breeze.
|
|
19
|
+
*/
|
|
20
|
+
export declare function breezeAt(elapsed: number, base: number, seed?: number): Breeze;
|
|
21
|
+
/** The breeze a tree sways in: the moment, its strength, the tree's height, and the way it blows (0, +x). */
|
|
22
|
+
export interface Gust {
|
|
23
|
+
readonly elapsed: number;
|
|
24
|
+
readonly wind: number;
|
|
25
|
+
readonly height: number;
|
|
26
|
+
readonly dir?: number | undefined;
|
|
27
|
+
}
|
|
28
|
+
/** The air a leaf flutters in: the moment and the wind's strength. */
|
|
29
|
+
export interface Airflow {
|
|
30
|
+
readonly elapsed: number;
|
|
31
|
+
readonly wind: number;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Wind bends the tree as one smooth field over space, so a joint moves exactly
|
|
35
|
+
* as both internodes that meet there: the branches flex and never come apart.
|
|
36
|
+
* The crown leans downwind, more as each gust rolls through from upwind and
|
|
37
|
+
* eases back after it; limbs far from the trunk give a little more. In still
|
|
38
|
+
* air it only breathes.
|
|
39
|
+
*/
|
|
40
|
+
export declare function sway(out: Offset, at: V3, breeze: Gust): Offset;
|
|
41
|
+
export interface Flutter {
|
|
42
|
+
readonly droop: number;
|
|
43
|
+
readonly twist: number;
|
|
44
|
+
readonly nod: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* How a leaf moves on its own, in radians. In still air it barely stirs; a
|
|
48
|
+
* breeze sets it trembling a little, and a passing gust lifts and flips it to
|
|
49
|
+
* show the paler underside before it settles back.
|
|
50
|
+
*/
|
|
51
|
+
export declare function leafFlutter(air: Airflow, rank: number, phase: number, along?: number): Flutter;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './tree-render/index.js'
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"protocol": "keel-module-inputs@1",
|
|
3
|
+
"fields": [
|
|
4
|
+
{
|
|
5
|
+
"key": "features",
|
|
6
|
+
"label": "Parts",
|
|
7
|
+
"required": false,
|
|
8
|
+
"help": "Feature switches as a plugin string, for example \"-roots,-litter\". Parts: roots, leaves, flowers, fruit, deadwood, litter, snow, fallers, sway, shadows, crownShade, bark, sprays, clumps, rootSink, rootBreak.",
|
|
9
|
+
"type": "text",
|
|
10
|
+
"minLength": 0,
|
|
11
|
+
"maxLength": 240,
|
|
12
|
+
"multiline": false,
|
|
13
|
+
"default": ""
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"key": "form",
|
|
17
|
+
"label": "Form",
|
|
18
|
+
"required": false,
|
|
19
|
+
"type": "select",
|
|
20
|
+
"options": [
|
|
21
|
+
{
|
|
22
|
+
"value": "smooth",
|
|
23
|
+
"label": "Smooth"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"value": "voxel",
|
|
27
|
+
"label": "Voxel"
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"default": "smooth"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"key": "forestNear",
|
|
34
|
+
"label": "Forest card distance",
|
|
35
|
+
"required": false,
|
|
36
|
+
"help": "Past this distance from the camera, forest trees draw as impostor cards.",
|
|
37
|
+
"type": "number",
|
|
38
|
+
"min": 4,
|
|
39
|
+
"max": 200,
|
|
40
|
+
"step": 1,
|
|
41
|
+
"control": "slider",
|
|
42
|
+
"default": 26
|
|
43
|
+
}
|
|
44
|
+
]
|
|
45
|
+
}
|