@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,41 @@
|
|
|
1
|
+
import type { GeometryLike, LitLike, MaterialLike, TreeColors, TreeModelLike, YearLike } from "../inputs.js";
|
|
2
|
+
import type { ForestVariant } from "./forest.js";
|
|
3
|
+
export interface Vector4Like {
|
|
4
|
+
x: number;
|
|
5
|
+
y: number;
|
|
6
|
+
z: number;
|
|
7
|
+
w: number;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* What a tree is cut down to at one level: real wood down to `wood`, up to `leaves` real leaves (`fill` blades each
|
|
11
|
+
* when they are few), and, for `clumps`, the crown's own masses as lumps under them.
|
|
12
|
+
*/
|
|
13
|
+
export interface RungSpec {
|
|
14
|
+
readonly wood: number;
|
|
15
|
+
readonly sides: number;
|
|
16
|
+
readonly leaves: number;
|
|
17
|
+
readonly fill: number;
|
|
18
|
+
/** Blades smaller than the bake's, which draws fewer and larger. */
|
|
19
|
+
readonly leafSize?: number;
|
|
20
|
+
/** Flat needles on each conifer sprig. */
|
|
21
|
+
readonly needles: number;
|
|
22
|
+
readonly clumps: number;
|
|
23
|
+
}
|
|
24
|
+
/** Card size: half width, height, and the base's drop below the origin. */
|
|
25
|
+
export interface Box {
|
|
26
|
+
readonly half: number;
|
|
27
|
+
readonly height: number;
|
|
28
|
+
readonly base: number;
|
|
29
|
+
}
|
|
30
|
+
export declare function bakedGeometry(lit: LitLike, variant: ForestVariant, spec: RungSpec): GeometryLike;
|
|
31
|
+
export declare function boxOf(geometry: GeometryLike): Box;
|
|
32
|
+
export declare function seasonUniforms(lit: LitLike, colors: TreeColors): Record<string, {
|
|
33
|
+
value: unknown;
|
|
34
|
+
}>;
|
|
35
|
+
/** A standard material that keeps the season on the GPU, sways, and dithers out by distance and near the lens. */
|
|
36
|
+
export declare function forestMaterial(lit: LitLike, uniforms: Record<string, {
|
|
37
|
+
value: unknown;
|
|
38
|
+
}>, card: boolean): MaterialLike;
|
|
39
|
+
export declare function setYear(uniforms: Record<string, {
|
|
40
|
+
value: unknown;
|
|
41
|
+
}>, year: YearLike, model: TreeModelLike, colors: TreeColors): void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { InstancedLike, MaterialLike } from "../inputs.js";
|
|
2
|
+
import type { CardRow, ForestLitLike, RendererLike, Vector4Like } from "./forest.js";
|
|
3
|
+
export declare const MAX_VARIANTS = 8;
|
|
4
|
+
export interface Cards {
|
|
5
|
+
readonly mesh: InstancedLike;
|
|
6
|
+
readonly material: MaterialLike;
|
|
7
|
+
readonly uniforms: Record<string, {
|
|
8
|
+
value: unknown;
|
|
9
|
+
}>;
|
|
10
|
+
readonly card: Float32Array;
|
|
11
|
+
readonly target: InstanceType<ForestLitLike["RenderTarget"]>;
|
|
12
|
+
readonly frames: number;
|
|
13
|
+
readonly cell: number;
|
|
14
|
+
/** The tree shapes the atlas is rendered from, kept while cards are drawn: the seasons re-render it. */
|
|
15
|
+
readonly rows: readonly CardRow[];
|
|
16
|
+
readonly capacity: number;
|
|
17
|
+
key: string;
|
|
18
|
+
idle: number;
|
|
19
|
+
}
|
|
20
|
+
/** How the cards are drawn: views round each tree, the pixel size of one, and the distance they take over at. */
|
|
21
|
+
export interface CardSheet {
|
|
22
|
+
readonly frames?: number | undefined;
|
|
23
|
+
readonly cell?: number | undefined;
|
|
24
|
+
readonly lod: Vector4Like;
|
|
25
|
+
}
|
|
26
|
+
export declare function createCards(lit: ForestLitLike, baked: readonly CardRow[], count: number, sheet: CardSheet): Cards;
|
|
27
|
+
/** Renders every variant from `frames` angles round it into one atlas row each. */
|
|
28
|
+
export declare function bakeCards(lit: ForestLitLike, renderer: RendererLike, cards: Cards, baked: readonly CardRow[]): void;
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
import type { ColorLike, GeometryLike, LitLike, MaterialLike, NodeLike, TreeColors, TreeFrameLike, TreeModelLike, Vector3Like, YearLike } from "../inputs.js";
|
|
2
|
+
import type { Box } from "./bake.js";
|
|
3
|
+
export type { Vector4Like } from "./bake.js";
|
|
4
|
+
/** One kind of background tree: a grown model posed once, in its species' colours. */
|
|
5
|
+
export interface ForestVariant {
|
|
6
|
+
readonly model: TreeModelLike;
|
|
7
|
+
readonly frame: TreeFrameLike;
|
|
8
|
+
readonly colors: TreeColors;
|
|
9
|
+
}
|
|
10
|
+
/** Where one background tree stands, which variant it is, and a brightness tint (1 as is). */
|
|
11
|
+
export interface ForestPlace {
|
|
12
|
+
readonly x: number;
|
|
13
|
+
readonly y: number;
|
|
14
|
+
readonly z: number;
|
|
15
|
+
readonly yaw: number;
|
|
16
|
+
readonly scale: number;
|
|
17
|
+
readonly variant: number;
|
|
18
|
+
readonly tint: number;
|
|
19
|
+
}
|
|
20
|
+
export interface ForestPlacesInput {
|
|
21
|
+
readonly seed: number;
|
|
22
|
+
readonly count: number;
|
|
23
|
+
readonly inner: number;
|
|
24
|
+
readonly outer: number;
|
|
25
|
+
readonly variants: number;
|
|
26
|
+
/** Ground height at (x, z), or null where no tree may stand (water, a road). */
|
|
27
|
+
readonly height: (x: number, z: number) => number | null;
|
|
28
|
+
/** Least room between two trees. */
|
|
29
|
+
readonly gap?: number;
|
|
30
|
+
readonly scale?: readonly [number, number];
|
|
31
|
+
/** 0 spreads trees evenly; 1 gathers them into groves with clearings between. */
|
|
32
|
+
readonly clump?: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Scatters trees over a ring by dart throwing: no two closer than `gap`,
|
|
36
|
+
* thinned into groves and clearings by a low-frequency field, each with its
|
|
37
|
+
* own variant, turn, size and shade.
|
|
38
|
+
*/
|
|
39
|
+
export declare function forestPlaces(input: ForestPlacesInput): ForestPlace[];
|
|
40
|
+
export interface ForestOptions {
|
|
41
|
+
readonly variants: readonly ForestVariant[];
|
|
42
|
+
readonly places: readonly ForestPlace[];
|
|
43
|
+
/** Beyond this distance from the camera a tree is an impostor card. */
|
|
44
|
+
readonly near?: number;
|
|
45
|
+
/** Dither band where geometry and card cross-fade. */
|
|
46
|
+
readonly band?: number;
|
|
47
|
+
/** Most leaves baked into one variant; the rest are skipped and the kept ones drawn larger. */
|
|
48
|
+
readonly maxLeaves?: number;
|
|
49
|
+
/** Twigs thinner than this are left out of the baked wood. */
|
|
50
|
+
readonly minRadius?: number;
|
|
51
|
+
/** Views round each variant on its impostor card (the sprite ladder). */
|
|
52
|
+
readonly frames?: number;
|
|
53
|
+
/** Pixel size of one impostor view. */
|
|
54
|
+
readonly cell?: number;
|
|
55
|
+
/** Near-lens dissolve: gone at [0], solid from [1] (view depth, world units). */
|
|
56
|
+
readonly fade?: readonly [number, number];
|
|
57
|
+
/** Updates a level may sit unused before it is freed. */
|
|
58
|
+
readonly keep?: number;
|
|
59
|
+
}
|
|
60
|
+
/** The light and air the forest sits in, from the host's scene. */
|
|
61
|
+
export interface ForestUpdate {
|
|
62
|
+
readonly camera: {
|
|
63
|
+
readonly position: {
|
|
64
|
+
readonly x: number;
|
|
65
|
+
readonly y: number;
|
|
66
|
+
readonly z: number;
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
/** Needed to bake impostors; without it every tree stays geometry. */
|
|
70
|
+
readonly renderer?: RendererLike | null;
|
|
71
|
+
readonly year: YearLike | ((variant: number) => YearLike);
|
|
72
|
+
readonly elapsed: number;
|
|
73
|
+
readonly wind: number;
|
|
74
|
+
/** Brightness of the baked cards (the scene's light colour, roughly ambient + sun). */
|
|
75
|
+
readonly light?: readonly [number, number, number];
|
|
76
|
+
readonly fog?: {
|
|
77
|
+
readonly color: readonly [number, number, number];
|
|
78
|
+
readonly near: number;
|
|
79
|
+
readonly far: number;
|
|
80
|
+
} | null;
|
|
81
|
+
/** Whole pixels to move the fades' dither by this frame (lit-finish's `ditherOffset()`); default still. */
|
|
82
|
+
readonly dither?: readonly [number, number];
|
|
83
|
+
}
|
|
84
|
+
export interface Forest {
|
|
85
|
+
readonly group: unknown;
|
|
86
|
+
/** Trees drawn at each level from the current view, the levels held, and the triangles drawn. */
|
|
87
|
+
readonly levels: {
|
|
88
|
+
readonly close: number;
|
|
89
|
+
readonly full: number;
|
|
90
|
+
readonly layered: number;
|
|
91
|
+
readonly cards: number;
|
|
92
|
+
readonly built: number;
|
|
93
|
+
readonly triangles: number;
|
|
94
|
+
};
|
|
95
|
+
update(input: ForestUpdate): void;
|
|
96
|
+
/** Moves, adds or removes trees without rebuilding anything already built. */
|
|
97
|
+
setPlaces(places: readonly ForestPlace[]): void;
|
|
98
|
+
dispose(): void;
|
|
99
|
+
}
|
|
100
|
+
/** The renderer calls the impostor bake makes. Pass the WebGLRenderer itself. */
|
|
101
|
+
export interface RendererLike {
|
|
102
|
+
getRenderTarget(): unknown;
|
|
103
|
+
setRenderTarget(target: unknown): void;
|
|
104
|
+
getClearColor(target: ColorLike): ColorLike;
|
|
105
|
+
getClearAlpha(): number;
|
|
106
|
+
setClearColor(color: ColorLike, alpha: number): void;
|
|
107
|
+
clear(color?: boolean, depth?: boolean, stencil?: boolean): void;
|
|
108
|
+
render(scene: unknown, camera: unknown): void;
|
|
109
|
+
autoClear: boolean;
|
|
110
|
+
}
|
|
111
|
+
/** keel/lit parts the forest needs beyond the tree's. */
|
|
112
|
+
export interface ForestLitLike extends LitLike {
|
|
113
|
+
readonly Stage: new () => NodeLike;
|
|
114
|
+
readonly OrthoCamera: new (left: number, right: number, top: number, bottom: number, near: number, far: number) => NodeLike & {
|
|
115
|
+
lookAt(x: number, y: number, z: number): void;
|
|
116
|
+
updateProjectionMatrix(): void;
|
|
117
|
+
};
|
|
118
|
+
readonly RenderTarget: new (width: number, height: number, options?: Readonly<Record<string, unknown>>) => {
|
|
119
|
+
readonly texture: unknown;
|
|
120
|
+
viewport: {
|
|
121
|
+
set(x: number, y: number, w: number, h: number): void;
|
|
122
|
+
};
|
|
123
|
+
scissor: {
|
|
124
|
+
set(x: number, y: number, w: number, h: number): void;
|
|
125
|
+
};
|
|
126
|
+
scissorTest: boolean;
|
|
127
|
+
dispose(): void;
|
|
128
|
+
};
|
|
129
|
+
readonly SkyLight: new (sky: string, ground: string, intensity: number) => NodeLike;
|
|
130
|
+
readonly SunLight: new (color: string, intensity: number) => NodeLike;
|
|
131
|
+
readonly Matrix4: new () => {
|
|
132
|
+
readonly elements: number[];
|
|
133
|
+
makeRotationY(angle: number): unknown;
|
|
134
|
+
compose(position: unknown, quaternion: unknown, scale: unknown): unknown;
|
|
135
|
+
};
|
|
136
|
+
readonly Quaternion: new () => {
|
|
137
|
+
setFromAxisAngle(axis: Vector3Like, angle: number): unknown;
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
export interface CardRow {
|
|
141
|
+
readonly geometry: GeometryLike;
|
|
142
|
+
readonly material: MaterialLike;
|
|
143
|
+
readonly box: Box;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Many trees, cheaply, at any distance. Every level is cut from the real tree
|
|
147
|
+
* and nobody asks for one: the richest (all its wood, its leaves filled out)
|
|
148
|
+
* near the eye, the plain bake to `near`, then its big wood and real crown
|
|
149
|
+
* masses under a few big leaves, then an impostor card from an atlas of baked
|
|
150
|
+
* views. Each level is one instanced mesh shared by every tree that needs it,
|
|
151
|
+
* built the first time a tree comes within its distance, crossed to and from on a
|
|
152
|
+
* dither, and freed again once nothing has used it for a while; two forests of the
|
|
153
|
+
* same tree share one shape. A forest seen only from afar never builds its
|
|
154
|
+
* near levels, and one seen only close never builds cards. Nothing is drawn right at the lens.
|
|
155
|
+
*/
|
|
156
|
+
export declare function createForest(lit: ForestLitLike, options: ForestOptions): Forest;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trees as objects. The tree-growth module grows a branch graph; this module
|
|
3
|
+
* draws it with KEEL's lit renderer (keel/lit): wood with surface roots, leaf blades that grow from
|
|
4
|
+
* their twigs and flutter, flowers and fruit that open, ripen and fall, litter
|
|
5
|
+
* under the crown, snow along the limbs, and the leaves and petals falling in
|
|
6
|
+
* between. One wind field bends wood, leaves and fruit together, so nothing
|
|
7
|
+
* comes apart at a joint. MIT.
|
|
8
|
+
*
|
|
9
|
+
* Every part has a switch (`roots`, `leaves`, `flowers`, `fruit`, `deadwood`,
|
|
10
|
+
* `litter`, `snow`, `fallers`, `sway`, `shadows`, `crownShade`, `bark`), set in
|
|
11
|
+
* code or from a plugin string such as "-roots,-litter". Three more switch the
|
|
12
|
+
* pixel-scale looks: `sprays` (blossoms open as a few big two-tone sprays per
|
|
13
|
+
* twig, not a speckle of tiny flowers), `clumps` (a twig's leaves share one
|
|
14
|
+
* tone, so the crown reads as lit and shaded masses) and `rootSink` (roots
|
|
15
|
+
* dive under the soil where they thin out or leave the inner planter). A host decides the
|
|
16
|
+
* ground: open soil, or a planter whose lip and wall the roots climb over.
|
|
17
|
+
* `rootBreak` lets an old tree's big roots heave the soil, crack the rim and
|
|
18
|
+
* now and then burst out through the planter's side.
|
|
19
|
+
*
|
|
20
|
+
* The same pieces draw a whole forest in the background (createForest): each
|
|
21
|
+
* tree variant is cut into levels of detail that keep their season on the GPU,
|
|
22
|
+
* each instanced many times and built only when a tree reaches its distance,
|
|
23
|
+
* ending in impostor cards baked from it (a sprite ladder), with a dither
|
|
24
|
+
* dissolve near the lens.
|
|
25
|
+
*
|
|
26
|
+
* const tree = createTreeRender(lit, model, { colors, ground: { y: 0, radius: 4.4 } });
|
|
27
|
+
* scene.add(tree.group);
|
|
28
|
+
* // every frame:
|
|
29
|
+
* tree.update(treeFrame(model, cycle), yearState(...), { elapsed, delta, wind });
|
|
30
|
+
*
|
|
31
|
+
* keel/lit is injected: the module never imports it and never touches globals.
|
|
32
|
+
*/
|
|
33
|
+
export type { SlotsLike, OrnamentSpecLike, TreeModelLike, TreeFrameLike, YearLike, TreeColors, TreeGround, TreeSkin, TreeStrain, TreeKindOrnaments, TreeBloom, GeometryLike, MaterialLike, InstancedLike, LitLike, } from "./inputs.js";
|
|
34
|
+
export { TREE_FEATURES, treeFeatures } from "./features.js";
|
|
35
|
+
export type { TreeFeature, TreeFeatures } from "./features.js";
|
|
36
|
+
export { smoothstep, hash32, seededRandom } from "./math.js";
|
|
37
|
+
export { breezeAt, sway, leafFlutter } from "./wind.js";
|
|
38
|
+
export type { Offset, Breeze, Flutter, Gust, Airflow } from "./wind.js";
|
|
39
|
+
export { clearSlot, writeBox, writeSlab, writeVoxel, writeSegment, writeBlade } from "./instances.js";
|
|
40
|
+
export type { V3, BoxPlace, VoxelLook, Limb, SlabSize, WoodPiece, Blade } from "./instances.js";
|
|
41
|
+
export { LEAF_OUTLINE, bladeGeometry, softBladeGeometry, sprayGeometry, lightSprig, needleGeometry, PALM_LEAFLET, speciesBlade, treeShapes, } from "./tree/shapes.js";
|
|
42
|
+
export type { TreeShapes, NeedleKind } from "./tree/shapes.js";
|
|
43
|
+
export { barkMaterial, ORNAMENTS, ornamentLook } from "./tree/bark.js";
|
|
44
|
+
export type { OrnamentLook } from "./tree/bark.js";
|
|
45
|
+
export { ROOT_SEGMENTS, NO_ROOT_BREAK, rootBreaks, rootPath, ROOT_SHARDS, rootShards } from "./tree/roots.js";
|
|
46
|
+
export type { RootPoint, RootBreak, RootShard, Breakage } from "./tree/roots.js";
|
|
47
|
+
export { createTreeRender } from "./tree/tree.js";
|
|
48
|
+
export type { TreeLimits, TreeRenderOptions, TreeMotion, TreeMeshes, TreeRender, TreeFruit } from "./tree/tree.js";
|
|
49
|
+
export { writeShard } from "./tree/wood.js";
|
|
50
|
+
export { crownShade } from "./tree/leaves.js";
|
|
51
|
+
export { forestPlaces, createForest } from "./forest/forest.js";
|
|
52
|
+
export type { ForestVariant, ForestPlace, ForestPlacesInput, ForestOptions, ForestUpdate, Forest, RendererLike, ForestLitLike, } from "./forest/forest.js";
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
/** Leaf, flower or fruit places on a grown tree. */
|
|
2
|
+
export interface SlotsLike {
|
|
3
|
+
readonly count: number;
|
|
4
|
+
readonly node: ArrayLike<number>;
|
|
5
|
+
readonly dx: ArrayLike<number>;
|
|
6
|
+
readonly dy: ArrayLike<number>;
|
|
7
|
+
readonly dz: ArrayLike<number>;
|
|
8
|
+
readonly rank: ArrayLike<number>;
|
|
9
|
+
readonly size: ArrayLike<number>;
|
|
10
|
+
readonly tone: ArrayLike<number>;
|
|
11
|
+
}
|
|
12
|
+
export interface OrnamentSpecLike {
|
|
13
|
+
readonly kind: string;
|
|
14
|
+
readonly on: "spur" | "tip";
|
|
15
|
+
readonly from: number;
|
|
16
|
+
}
|
|
17
|
+
export interface TreeModelLike {
|
|
18
|
+
readonly count: number;
|
|
19
|
+
readonly birth: ArrayLike<number>;
|
|
20
|
+
readonly phase: ArrayLike<number>;
|
|
21
|
+
readonly leaves: SlotsLike;
|
|
22
|
+
readonly blossoms: SlotsLike;
|
|
23
|
+
readonly fruit: SlotsLike;
|
|
24
|
+
readonly roots: readonly {
|
|
25
|
+
readonly angle: number;
|
|
26
|
+
readonly reach: number;
|
|
27
|
+
}[];
|
|
28
|
+
/**
|
|
29
|
+
* Each internode's parent (-1 for the root) and branch order (0 for the trunk): palms need them to lay out their
|
|
30
|
+
* fronds.
|
|
31
|
+
*/
|
|
32
|
+
readonly parent?: ArrayLike<number>;
|
|
33
|
+
readonly order?: ArrayLike<number>;
|
|
34
|
+
readonly species: {
|
|
35
|
+
readonly id: string;
|
|
36
|
+
/** Set for palms, whose leaves are the leaflets of their fronds. */
|
|
37
|
+
readonly palm?: unknown;
|
|
38
|
+
readonly evergreen: boolean;
|
|
39
|
+
readonly flower: OrnamentSpecLike | null;
|
|
40
|
+
readonly fruit: OrnamentSpecLike | null;
|
|
41
|
+
readonly phenology: {
|
|
42
|
+
readonly dropMax: number;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
export interface TreeFrameLike {
|
|
47
|
+
readonly cycle: number;
|
|
48
|
+
readonly grow: ArrayLike<number>;
|
|
49
|
+
readonly radius: ArrayLike<number>;
|
|
50
|
+
readonly dead: ArrayLike<number>;
|
|
51
|
+
readonly fall: ArrayLike<number>;
|
|
52
|
+
readonly rot: ArrayLike<number>;
|
|
53
|
+
readonly tips: ArrayLike<number>;
|
|
54
|
+
readonly x: ArrayLike<number>;
|
|
55
|
+
readonly y: ArrayLike<number>;
|
|
56
|
+
readonly z: ArrayLike<number>;
|
|
57
|
+
readonly baseX: ArrayLike<number>;
|
|
58
|
+
readonly baseY: ArrayLike<number>;
|
|
59
|
+
readonly baseZ: ArrayLike<number>;
|
|
60
|
+
readonly visible: number;
|
|
61
|
+
readonly height: number;
|
|
62
|
+
/** How much bigger than life a grand tree has grown (tree-growth's `grand` frames); leaf clumps grow with it. */
|
|
63
|
+
readonly scale?: number;
|
|
64
|
+
}
|
|
65
|
+
export interface YearLike {
|
|
66
|
+
readonly bloom: number;
|
|
67
|
+
readonly petals: number;
|
|
68
|
+
readonly fruit: number;
|
|
69
|
+
readonly fruitDrop: number;
|
|
70
|
+
readonly withered: boolean;
|
|
71
|
+
readonly leaf: number;
|
|
72
|
+
readonly color: number;
|
|
73
|
+
readonly drop: number;
|
|
74
|
+
readonly litter: number;
|
|
75
|
+
readonly flush: number;
|
|
76
|
+
}
|
|
77
|
+
/** The species' colours: three of each, darkest first. */
|
|
78
|
+
export interface TreeColors {
|
|
79
|
+
readonly trunk: readonly string[];
|
|
80
|
+
readonly leaves: readonly string[];
|
|
81
|
+
readonly spring: readonly string[];
|
|
82
|
+
readonly autumn: readonly string[];
|
|
83
|
+
/** Leaf size in world units. */
|
|
84
|
+
readonly leafScale: number;
|
|
85
|
+
/** Spring is blossom (cherry): new leaves flush pale, not pink. */
|
|
86
|
+
readonly blossom?: boolean;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Where the tree stands. `radius` bounds litter and fallers. A planter passes
|
|
90
|
+
* `lip` (its top's reach at each angle) and `wall` so roots roll over the edge
|
|
91
|
+
* and creep down; `surface` lets them follow a carved wall.
|
|
92
|
+
*/
|
|
93
|
+
export interface TreeGround {
|
|
94
|
+
readonly y: number;
|
|
95
|
+
readonly radius: number;
|
|
96
|
+
/** Longest a surface root may run (defaults to `radius`). */
|
|
97
|
+
readonly rootReach?: number;
|
|
98
|
+
readonly lip?: (angle: number) => number;
|
|
99
|
+
readonly wall?: {
|
|
100
|
+
readonly depth: number;
|
|
101
|
+
readonly flare: number;
|
|
102
|
+
};
|
|
103
|
+
readonly surface?: (angle: number, y: number) => number;
|
|
104
|
+
/**
|
|
105
|
+
* The planter itself, for the chunks an old tree's roots break out of it
|
|
106
|
+
* (`rootBreak`). `colors` are its stone, darkest first (left out, a
|
|
107
|
+
* weathered grey); `hard` keeps roots from bursting its side (metal, gems:
|
|
108
|
+
* they only crack the rim; left out, a wall roots do not creep down, depth
|
|
109
|
+
* under half a unit, counts as hard); `hang` is how far below the wall's
|
|
110
|
+
* foot a burst root may dangle free (left out, a little more than the wall's depth).
|
|
111
|
+
*/
|
|
112
|
+
readonly planter?: {
|
|
113
|
+
readonly colors?: readonly string[];
|
|
114
|
+
readonly hard?: boolean;
|
|
115
|
+
readonly hang?: number;
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
/** A material skin: the crown takes these colours instead of the species' own. */
|
|
119
|
+
export interface TreeSkin {
|
|
120
|
+
readonly leaves: readonly string[];
|
|
121
|
+
readonly leafSize?: number;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Another strain in a hybrid or chimera tree: the limbs `strainOf` gives it
|
|
125
|
+
* take these colours and this skin instead of the tree's own. `colors` left
|
|
126
|
+
* out keeps the tree's; `skin` left out keeps the tree's skin, `null` drops it
|
|
127
|
+
* (a natural limb on a crystal tree).
|
|
128
|
+
*/
|
|
129
|
+
export interface TreeStrain {
|
|
130
|
+
readonly colors?: TreeColors;
|
|
131
|
+
readonly skin?: TreeSkin | null;
|
|
132
|
+
/**
|
|
133
|
+
* False when the strain's own kind would not flower or fruit like the tree (an oak limb on a cherry stays green in
|
|
134
|
+
* blossom time).
|
|
135
|
+
*/
|
|
136
|
+
readonly bears?: boolean;
|
|
137
|
+
/** Bark colours for the strain's wood, darkest first (a skin's own bark); left out, the strain's `colors.trunk`. */
|
|
138
|
+
readonly bark?: readonly string[];
|
|
139
|
+
/** The strain's own kind: a broadleaf limb on a conifer keeps broad leaves, not needles. */
|
|
140
|
+
readonly species?: string;
|
|
141
|
+
/** Its leaves hang in strands this long below the twig, world units (a willow's limbs weep on any tree). */
|
|
142
|
+
readonly hang?: number;
|
|
143
|
+
}
|
|
144
|
+
/** A hybrid's minor kind's own flowers and fruit, hanging on its limbs (tree-growth `kindOrnaments`). */
|
|
145
|
+
export interface TreeKindOrnaments {
|
|
146
|
+
/** The kind's species id, for the look of its flowers and fruit. */
|
|
147
|
+
readonly species: string;
|
|
148
|
+
/** The strain whose year (`TreeMotion.strainYears`) opens and drops them. */
|
|
149
|
+
readonly strain: number;
|
|
150
|
+
readonly flower?: {
|
|
151
|
+
readonly spec: OrnamentSpecLike;
|
|
152
|
+
readonly slots: SlotsLike;
|
|
153
|
+
} | null;
|
|
154
|
+
readonly fruit?: {
|
|
155
|
+
readonly spec: OrnamentSpecLike;
|
|
156
|
+
readonly slots: SlotsLike;
|
|
157
|
+
} | null;
|
|
158
|
+
}
|
|
159
|
+
/** One blossom colour in a mixed bloom: this share of the flowers opens in these colours. */
|
|
160
|
+
export interface TreeBloom {
|
|
161
|
+
readonly colors: readonly string[];
|
|
162
|
+
readonly share: number;
|
|
163
|
+
}
|
|
164
|
+
export interface ColorLike {
|
|
165
|
+
r: number;
|
|
166
|
+
g: number;
|
|
167
|
+
b: number;
|
|
168
|
+
set(value: string | number): ColorLike;
|
|
169
|
+
setRGB(r: number, g: number, b: number): ColorLike;
|
|
170
|
+
copy(color: ColorLike): ColorLike;
|
|
171
|
+
lerp(color: ColorLike, t: number): ColorLike;
|
|
172
|
+
multiplyScalar(s: number): ColorLike;
|
|
173
|
+
offsetHSL(h: number, s: number, l: number): ColorLike;
|
|
174
|
+
getHexString(): string;
|
|
175
|
+
}
|
|
176
|
+
interface AttributeLike {
|
|
177
|
+
readonly count: number;
|
|
178
|
+
readonly array: Float32Array;
|
|
179
|
+
needsUpdate: boolean;
|
|
180
|
+
readonly itemSize: number;
|
|
181
|
+
}
|
|
182
|
+
export interface GeometryLike {
|
|
183
|
+
readonly index?: unknown;
|
|
184
|
+
readonly attributes: Readonly<Record<string, AttributeLike | undefined>>;
|
|
185
|
+
setAttribute(name: string, attribute: unknown): GeometryLike;
|
|
186
|
+
computeVertexNormals(): void;
|
|
187
|
+
toNonIndexed(): GeometryLike;
|
|
188
|
+
translate(x: number, y: number, z: number): GeometryLike;
|
|
189
|
+
scale(x: number, y: number, z: number): GeometryLike;
|
|
190
|
+
dispose(): void;
|
|
191
|
+
}
|
|
192
|
+
interface ShaderLike {
|
|
193
|
+
vertexShader: string;
|
|
194
|
+
fragmentShader: string;
|
|
195
|
+
uniforms: Record<string, {
|
|
196
|
+
value: unknown;
|
|
197
|
+
}>;
|
|
198
|
+
}
|
|
199
|
+
export interface MaterialLike {
|
|
200
|
+
dispose(): void;
|
|
201
|
+
onCompile: (shader: ShaderLike) => void;
|
|
202
|
+
customProgramCacheKey: () => string;
|
|
203
|
+
userData: Record<string, unknown>;
|
|
204
|
+
color: ColorLike;
|
|
205
|
+
needsUpdate: boolean;
|
|
206
|
+
}
|
|
207
|
+
export interface Vector3Like {
|
|
208
|
+
x: number;
|
|
209
|
+
y: number;
|
|
210
|
+
z: number;
|
|
211
|
+
set(x: number, y: number, z: number): Vector3Like;
|
|
212
|
+
}
|
|
213
|
+
export interface NodeLike {
|
|
214
|
+
visible: boolean;
|
|
215
|
+
castShadow: boolean;
|
|
216
|
+
receiveShadow: boolean;
|
|
217
|
+
frustumCulled: boolean;
|
|
218
|
+
renderOrder: number;
|
|
219
|
+
position: Vector3Like;
|
|
220
|
+
userData: Record<string, unknown>;
|
|
221
|
+
add(...objects: unknown[]): void;
|
|
222
|
+
remove(...objects: unknown[]): void;
|
|
223
|
+
}
|
|
224
|
+
export interface InstancedLike extends NodeLike {
|
|
225
|
+
count: number;
|
|
226
|
+
geometry: GeometryLike;
|
|
227
|
+
material: MaterialLike;
|
|
228
|
+
readonly instanceMatrix: {
|
|
229
|
+
readonly array: Float32Array;
|
|
230
|
+
needsUpdate: boolean;
|
|
231
|
+
setUsage(usage: unknown): void;
|
|
232
|
+
};
|
|
233
|
+
instanceColor: {
|
|
234
|
+
needsUpdate: boolean;
|
|
235
|
+
} | null;
|
|
236
|
+
setColorAt(index: number, color: ColorLike): void;
|
|
237
|
+
dispose(): void;
|
|
238
|
+
}
|
|
239
|
+
interface MeshLike extends NodeLike {
|
|
240
|
+
geometry: GeometryLike;
|
|
241
|
+
material: MaterialLike;
|
|
242
|
+
}
|
|
243
|
+
/** The parts of keel/lit this module calls. Pass the keel/lit namespace itself. */
|
|
244
|
+
export interface LitLike {
|
|
245
|
+
readonly Group: new () => NodeLike;
|
|
246
|
+
readonly Mesh: new (geometry: unknown, material: unknown) => MeshLike;
|
|
247
|
+
readonly Instances: new (geometry: unknown, material: unknown, count: number) => InstancedLike;
|
|
248
|
+
readonly Geometry: new () => GeometryLike;
|
|
249
|
+
readonly Attribute: new (array: Float32Array, itemSize: number) => AttributeLike;
|
|
250
|
+
readonly InstanceAttribute: new (array: Float32Array, itemSize: number) => AttributeLike;
|
|
251
|
+
box(x: number, y: number, z: number): GeometryLike;
|
|
252
|
+
cylinder(top: number, bottom: number, height: number, radial: number, rows: number): GeometryLike;
|
|
253
|
+
icosahedron(radius: number, detail: number): GeometryLike;
|
|
254
|
+
plane(width: number, height: number): GeometryLike;
|
|
255
|
+
readonly LitMaterial: new (parameters: Readonly<Record<string, unknown>>) => MaterialLike;
|
|
256
|
+
readonly CustomMaterial: new (parameters: Readonly<Record<string, unknown>>) => MaterialLike;
|
|
257
|
+
readonly Color: new (value?: string) => ColorLike;
|
|
258
|
+
readonly Vector3: new (x?: number, y?: number, z?: number) => Vector3Like;
|
|
259
|
+
}
|
|
260
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { Flutter } from "./wind.js";
|
|
2
|
+
export declare function writeColumns(array: Float32Array, index: number, columns: readonly number[]): void;
|
|
3
|
+
export declare function writeOrigin(array: Float32Array, index: number, origin: readonly [number, number, number]): void;
|
|
4
|
+
/** Hides one instance far below the scene, scaled to nothing. */
|
|
5
|
+
export declare function clearSlot(array: Float32Array, index: number): void;
|
|
6
|
+
export type V3 = readonly [number, number, number];
|
|
7
|
+
/** A box's place: its origin, its size along each axis, and its turn about up. */
|
|
8
|
+
export interface BoxPlace {
|
|
9
|
+
readonly at: V3;
|
|
10
|
+
readonly size: V3;
|
|
11
|
+
readonly yaw: number;
|
|
12
|
+
}
|
|
13
|
+
/** A box turned `yaw` about up, scaled by `size`. */
|
|
14
|
+
export declare function writeBox(array: Float32Array, index: number, box: BoxPlace): void;
|
|
15
|
+
/** A limb a slab lies on: its middle, the way it runs, and its radius. */
|
|
16
|
+
export interface Limb {
|
|
17
|
+
readonly at: V3;
|
|
18
|
+
readonly along: V3;
|
|
19
|
+
readonly radius: number;
|
|
20
|
+
}
|
|
21
|
+
/** A slab's size: across the limb, through, and along it. */
|
|
22
|
+
export interface SlabSize {
|
|
23
|
+
readonly width: number;
|
|
24
|
+
readonly depth: number;
|
|
25
|
+
readonly long: number;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* A slab `width` wide and `depth` thick lying on the top of a limb from its middle along (dx, dy, dz), which it follows
|
|
29
|
+
* however it slopes.
|
|
30
|
+
*/
|
|
31
|
+
export declare function writeSlab(array: Float32Array, index: number, limb: Limb, slab: SlabSize): void;
|
|
32
|
+
/** A voxel's look: how wide it is, how it is turned, and how much it is flattened (1, the default, is a cube). */
|
|
33
|
+
export interface VoxelLook {
|
|
34
|
+
readonly size: number;
|
|
35
|
+
readonly yaw: number;
|
|
36
|
+
readonly flat?: number;
|
|
37
|
+
}
|
|
38
|
+
/** A cube `size` wide, flattened by `flat`, turned `yaw`. */
|
|
39
|
+
export declare function writeVoxel(array: Float32Array, index: number, at: V3, voxel: VoxelLook): void;
|
|
40
|
+
/** One piece of wood: from `a` to `b`, `radius` thick. */
|
|
41
|
+
export interface WoodPiece {
|
|
42
|
+
readonly a: V3;
|
|
43
|
+
readonly b: V3;
|
|
44
|
+
readonly radius: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* One wood piece from a to b, `radius` thick, overlapping its joints. Rotation is the shortest arc from up, so bark
|
|
48
|
+
* never swims.
|
|
49
|
+
*/
|
|
50
|
+
export declare function writeSegment(array: Float32Array, index: number, piece: WoodPiece): void;
|
|
51
|
+
export declare const UP: readonly [number, number, number];
|
|
52
|
+
export declare const norm3: (x: number, y: number, z: number) => [number, number, number];
|
|
53
|
+
export declare const cross3: (a: V3, b: V3) => [number, number, number];
|
|
54
|
+
export declare const isZero: (v: V3) => boolean;
|
|
55
|
+
/** One leaf blade: its stalk `p`, the way it points `n`, its size, and `long` times longer than wide (1). */
|
|
56
|
+
export interface Blade {
|
|
57
|
+
readonly p: V3;
|
|
58
|
+
readonly n: V3;
|
|
59
|
+
readonly size: number;
|
|
60
|
+
readonly long?: number;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* One leaf blade at its stalk, pointing along `n`, drooped, twisted and nodded by `motion`; `long` draws it
|
|
64
|
+
* that much longer than wide.
|
|
65
|
+
*/
|
|
66
|
+
export declare function writeBlade(array: Float32Array, index: number, blade: Blade, motion: Flutter): void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const TAU: number;
|
|
2
|
+
export declare const clamp: (value: number, low: number, high: number) => number;
|
|
3
|
+
export declare const at: (array: ArrayLike<number>, index: number) => number;
|
|
4
|
+
export declare function smoothstep(edge0: number, edge1: number, value: number): number;
|
|
5
|
+
/** A stable 32-bit hash. */
|
|
6
|
+
export declare function hash32(value: number): number;
|
|
7
|
+
/** A small seeded stream (mulberry32). */
|
|
8
|
+
export declare function seededRandom(seed: number): () => number;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { LitLike, MaterialLike, OrnamentSpecLike } from "../inputs.js";
|
|
2
|
+
/**
|
|
3
|
+
* A standard material whose instances carry living bark. `ground` is the world y where moss gathers; `bareWall` keeps
|
|
4
|
+
* moss off roots below it (on a planter wall).
|
|
5
|
+
*/
|
|
6
|
+
export declare function barkMaterial(lit: LitLike, ground?: number, uprightMoss?: boolean, bareWall?: boolean): MaterialLike;
|
|
7
|
+
/**
|
|
8
|
+
* Flowers and fruit, per kind. Sizes are in leaf units (width, length, depth);
|
|
9
|
+
* `lift` moves them up from the twig (negative hangs below it). Fruit ripens
|
|
10
|
+
* from `green` to its colours; `fall` is how fast a dropped one falls.
|
|
11
|
+
*/
|
|
12
|
+
export interface OrnamentLook {
|
|
13
|
+
readonly size: readonly [number, number, number];
|
|
14
|
+
readonly lift: number;
|
|
15
|
+
readonly colors?: readonly string[];
|
|
16
|
+
readonly green?: string;
|
|
17
|
+
readonly fall: number;
|
|
18
|
+
}
|
|
19
|
+
export declare const ORNAMENTS: Readonly<Record<string, OrnamentLook>>;
|
|
20
|
+
export declare function ornamentLook(spec: OrnamentSpecLike, speciesId?: string): OrnamentLook;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { InstancedLike, SlotsLike, TreeFrameLike, TreeModelLike } from "../inputs.js";
|
|
2
|
+
import type { V3 } from "../instances.js";
|
|
3
|
+
import type { Tick, Tree } from "./tree.js";
|
|
4
|
+
/**
|
|
5
|
+
* A palm frond as its leaflets: two even rows down the rachis, one each side,
|
|
6
|
+
* short at the frond's base, longest a third of the way out and short again at
|
|
7
|
+
* its tip. Per leaflet: how far along its internode it grows, which side, and
|
|
8
|
+
* how far out along the whole frond that is.
|
|
9
|
+
*/
|
|
10
|
+
export interface FrondLayout {
|
|
11
|
+
readonly along: Float32Array;
|
|
12
|
+
readonly side: Float32Array;
|
|
13
|
+
readonly out: Float32Array;
|
|
14
|
+
readonly pieces: Float32Array;
|
|
15
|
+
}
|
|
16
|
+
export declare function frondLayout(model: TreeModelLike): FrondLayout | null;
|
|
17
|
+
/** Where a conifer sprig sits: somewhere along its twig, pointing the way the twig grows, a little off it. */
|
|
18
|
+
export declare function sprigPlace(frame: TreeFrameLike, slots: TreeModelLike["leaves"], index: number): {
|
|
19
|
+
p: V3;
|
|
20
|
+
n: V3;
|
|
21
|
+
};
|
|
22
|
+
export declare function poseLeaves(tree: Tree, mesh: InstancedLike, tick: Tick): void;
|
|
23
|
+
/**
|
|
24
|
+
* How lit each leaf is by its place in the crown: leaves deep inside and low
|
|
25
|
+
* down sit in the crown's own shade, the outer and upper ones catch the light,
|
|
26
|
+
* and each varies a little on its own. Without it a crown is one flat colour.
|
|
27
|
+
*/
|
|
28
|
+
export declare function crownShade(frame: TreeFrameLike, slots: SlotsLike, jitter?: (index: number) => number): Float32Array;
|
|
29
|
+
export declare function paintLeaves(tree: Tree, mesh: InstancedLike, tick: Tick): void;
|