@casmo/tree.js 0.4.0 → 0.5.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 +590 -4
- package/dist/effects/custom.d.ts +62 -0
- package/dist/effects/custom.d.ts.map +1 -0
- package/dist/effects/effects.d.ts +42 -1
- package/dist/effects/effects.d.ts.map +1 -1
- package/dist/effects/index.d.ts +2 -0
- package/dist/effects/index.d.ts.map +1 -1
- package/dist/effects/mask.d.ts +9 -1
- package/dist/effects/mask.d.ts.map +1 -1
- package/dist/effects/tree-id.d.ts.map +1 -1
- package/dist/effects-qHx_8Dlk.js +1052 -0
- package/dist/effects-qHx_8Dlk.js.map +1 -0
- package/dist/effects.js +2 -963
- package/dist/forest/Forest.d.ts +80 -4
- package/dist/forest/Forest.d.ts.map +1 -1
- package/dist/forest/forest-lod.d.ts +70 -0
- package/dist/forest/forest-lod.d.ts.map +1 -0
- package/dist/forest/impostor-material.d.ts +106 -0
- package/dist/forest/impostor-material.d.ts.map +1 -0
- package/dist/forest/impostor-season.d.ts +13 -0
- package/dist/forest/impostor-season.d.ts.map +1 -0
- package/dist/forest/impostor.d.ts +105 -0
- package/dist/forest/impostor.d.ts.map +1 -0
- package/dist/forest/index.d.ts +1 -0
- package/dist/forest/index.d.ts.map +1 -1
- package/dist/forest/levels.d.ts +144 -0
- package/dist/forest/levels.d.ts.map +1 -0
- package/dist/forest/lod.d.ts +106 -0
- package/dist/forest/lod.d.ts.map +1 -0
- package/dist/forest/nodes.d.ts +42 -1
- package/dist/forest/nodes.d.ts.map +1 -1
- package/dist/forest/octahedral.d.ts +33 -0
- package/dist/forest/octahedral.d.ts.map +1 -0
- package/dist/{forest-lg61rhKM.js → forest-CM5DrklM.js} +1723 -340
- package/dist/forest-CM5DrklM.js.map +1 -0
- package/dist/generator/fruit.d.ts +2 -0
- package/dist/generator/fruit.d.ts.map +1 -1
- package/dist/generator/index.d.ts +1 -0
- package/dist/generator/index.d.ts.map +1 -1
- package/dist/generator/light.d.ts +36 -0
- package/dist/generator/light.d.ts.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/materials/crown-nodes.d.ts +5 -0
- package/dist/materials/crown-nodes.d.ts.map +1 -1
- package/dist/materials/leaf-translucency-model.d.ts +6 -1
- package/dist/materials/leaf-translucency-model.d.ts.map +1 -1
- package/dist/materials/material-features.d.ts +12 -0
- package/dist/materials/material-features.d.ts.map +1 -1
- package/dist/materials/shader-hooks.d.ts +155 -0
- package/dist/materials/shader-hooks.d.ts.map +1 -0
- package/dist/motion-Qd7xjeZM.js +276 -0
- package/dist/motion-Qd7xjeZM.js.map +1 -0
- package/dist/nodes-DxgTyF9B.js +436 -0
- package/dist/nodes-DxgTyF9B.js.map +1 -0
- package/dist/react/Forest.d.ts +17 -3
- package/dist/react/Forest.d.ts.map +1 -1
- package/dist/react/ScenePipeline.d.ts +63 -0
- package/dist/react/ScenePipeline.d.ts.map +1 -0
- package/dist/react/SceneShaderHooks.d.ts +25 -0
- package/dist/react/SceneShaderHooks.d.ts.map +1 -0
- package/dist/react/Tree.d.ts +9 -2
- package/dist/react/Tree.d.ts.map +1 -1
- package/dist/react/Weather.d.ts +45 -0
- package/dist/react/Weather.d.ts.map +1 -0
- package/dist/react/Wind.d.ts +12 -1
- package/dist/react/Wind.d.ts.map +1 -1
- package/dist/react/index.d.ts +7 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react.js +347 -10
- package/dist/react.js.map +1 -1
- package/dist/renderer/index.d.ts +6 -0
- package/dist/renderer/index.d.ts.map +1 -1
- package/dist/scene/antialias.d.ts +35 -0
- package/dist/scene/antialias.d.ts.map +1 -0
- package/dist/scene/ao.d.ts +46 -0
- package/dist/scene/ao.d.ts.map +1 -0
- package/dist/scene/bloom.d.ts +19 -0
- package/dist/scene/bloom.d.ts.map +1 -0
- package/dist/scene/fog.d.ts +49 -0
- package/dist/scene/fog.d.ts.map +1 -0
- package/dist/scene/godrays.d.ts +37 -0
- package/dist/scene/godrays.d.ts.map +1 -0
- package/dist/scene/index.d.ts +14 -0
- package/dist/scene/index.d.ts.map +1 -0
- package/dist/scene/motion-blur.d.ts +23 -0
- package/dist/scene/motion-blur.d.ts.map +1 -0
- package/dist/scene/pipeline.d.ts +109 -0
- package/dist/scene/pipeline.d.ts.map +1 -0
- package/dist/scene/settings.d.ts +36 -0
- package/dist/scene/settings.d.ts.map +1 -0
- package/dist/scene/stack.d.ts +25 -0
- package/dist/scene/stack.d.ts.map +1 -0
- package/dist/scene/stage.d.ts +52 -0
- package/dist/scene/stage.d.ts.map +1 -0
- package/dist/scene/suggested.d.ts +12 -0
- package/dist/scene/suggested.d.ts.map +1 -0
- package/dist/scene/tone-mapping.d.ts +20 -0
- package/dist/scene/tone-mapping.d.ts.map +1 -0
- package/dist/scene/velocity.d.ts +34 -0
- package/dist/scene/velocity.d.ts.map +1 -0
- package/dist/scene.js +889 -0
- package/dist/scene.js.map +1 -0
- package/dist/season/nodes.d.ts +13 -0
- package/dist/season/nodes.d.ts.map +1 -1
- package/dist/shader-hooks-BFRtlWGI.js +275 -0
- package/dist/shader-hooks-BFRtlWGI.js.map +1 -0
- package/dist/tree/Tree.d.ts +8 -3
- package/dist/tree/Tree.d.ts.map +1 -1
- package/dist/tree/index.d.ts.map +1 -1
- package/dist/weather/index.d.ts +3 -0
- package/dist/weather/index.d.ts.map +1 -0
- package/dist/weather/shared.d.ts +43 -0
- package/dist/weather/shared.d.ts.map +1 -0
- package/dist/weather/snow.d.ts +87 -0
- package/dist/weather/snow.d.ts.map +1 -0
- package/dist/weather/wetness.d.ts +75 -0
- package/dist/weather/wetness.d.ts.map +1 -0
- package/dist/weather.js +288 -0
- package/dist/weather.js.map +1 -0
- package/dist/wind/Wind.d.ts +100 -5
- package/dist/wind/Wind.d.ts.map +1 -1
- package/dist/wind/burst.d.ts +28 -0
- package/dist/wind/burst.d.ts.map +1 -0
- package/dist/wind/index.d.ts +3 -2
- package/dist/wind/index.d.ts.map +1 -1
- package/dist/wind/motion.d.ts +30 -0
- package/dist/wind/motion.d.ts.map +1 -0
- package/dist/wind/node.d.ts +17 -3
- package/dist/wind/node.d.ts.map +1 -1
- package/package.json +9 -1
- package/dist/effects.js.map +0 -1
- package/dist/forest-lg61rhKM.js.map +0 -1
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { BufferGeometry, IndirectStorageBufferAttribute, Matrix4, Mesh, StorageBufferAttribute, Vector3, type Camera, type ComputeNode, type Material, type Object3D, type Renderer, type Scene, type UniformNode } from 'three/webgpu';
|
|
2
|
+
import { DetailLevel } from './lod';
|
|
3
|
+
/** Detail Levels a Variant can draw: Full, Light and Impostor. Lists and draw arguments have room for all three. */
|
|
4
|
+
export declare const LEVEL_COUNT = 3;
|
|
5
|
+
/** Meshes (materials) one Detail Level draws at most: wood, leaves and Fruit. */
|
|
6
|
+
export declare const MAX_LEVEL_PARTS = 3;
|
|
7
|
+
/** The live values every Variant's level selection reads (one set per Forest). */
|
|
8
|
+
export interface DetailLevelUniforms {
|
|
9
|
+
light: UniformNode<'float', number>;
|
|
10
|
+
impostor: UniformNode<'float', number>;
|
|
11
|
+
fade: UniformNode<'float', number>;
|
|
12
|
+
/** World position of the camera that picks the levels this frame. */
|
|
13
|
+
camera: UniformNode<'vec3', Vector3>;
|
|
14
|
+
/** The Forest's world matrix (tree positions are in forest space). */
|
|
15
|
+
forest: UniformNode<'mat4', Matrix4>;
|
|
16
|
+
/**
|
|
17
|
+
* The farthest Detail Level that can be drawn: Light until the Impostors are baked. Trees
|
|
18
|
+
* beyond it draw at it, without a cross-fade into the level that is not there.
|
|
19
|
+
*/
|
|
20
|
+
farthest: UniformNode<'uint', number>;
|
|
21
|
+
}
|
|
22
|
+
/** One mesh of a Detail Level: the geometry (shared vertex data) and the material it draws with. */
|
|
23
|
+
export interface LevelPart {
|
|
24
|
+
name: string;
|
|
25
|
+
geometry: BufferGeometry;
|
|
26
|
+
material: Material;
|
|
27
|
+
}
|
|
28
|
+
/** The meshes of one Detail Level of a Variant. */
|
|
29
|
+
export interface LevelMeshes {
|
|
30
|
+
level: DetailLevel;
|
|
31
|
+
meshes: Mesh[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The GPU side of one Variant's Detail Levels: the tree data by slot, one list of tree slots per
|
|
35
|
+
* level (with each entry's cross-fade), the indirect draw arguments, the compute pass that fills
|
|
36
|
+
* them, and the meshes of every level (they draw indirectly and read their trees by slot).
|
|
37
|
+
*
|
|
38
|
+
* - `setLevel(level, parts)` gives a level its meshes (Full and Light now; an Impostor card later).
|
|
39
|
+
* - `write(slot, …)` / `count` mirror the Variant's instance data; `resize(capacity)` keeps them.
|
|
40
|
+
* - `dispatches` run once per frame for the camera that picks the levels, before any of the meshes is drawn.
|
|
41
|
+
*/
|
|
42
|
+
export declare class VariantLevels {
|
|
43
|
+
private readonly uniforms;
|
|
44
|
+
private readonly setupMesh;
|
|
45
|
+
/** Every level's meshes, nearest level first. */
|
|
46
|
+
readonly levels: LevelMeshes[];
|
|
47
|
+
private capacityValue;
|
|
48
|
+
private treeData;
|
|
49
|
+
private lists;
|
|
50
|
+
private dithers;
|
|
51
|
+
private readonly counters;
|
|
52
|
+
private readonly args;
|
|
53
|
+
private readonly treeNode;
|
|
54
|
+
private readonly listNode;
|
|
55
|
+
private readonly ditherNode;
|
|
56
|
+
private readonly countNode;
|
|
57
|
+
private readonly levelOf;
|
|
58
|
+
private computeNodes;
|
|
59
|
+
/** Bumped whenever the trees change (data, count, capacity): the levels must be selected again. */
|
|
60
|
+
version: number;
|
|
61
|
+
/** What the meshes read per tree (see `drawsDetailLevel`). */
|
|
62
|
+
private readonly instance;
|
|
63
|
+
constructor(capacity: number, uniforms: DetailLevelUniforms, setupMesh: (mesh: Mesh) => void);
|
|
64
|
+
get capacity(): number;
|
|
65
|
+
/** Number of trees (slots 0..count-1 are in use). */
|
|
66
|
+
get count(): number;
|
|
67
|
+
set count(value: number);
|
|
68
|
+
/** The compute dispatches to run once per frame (reset, select, draw arguments). */
|
|
69
|
+
get dispatches(): readonly ComputeNode[];
|
|
70
|
+
/** Every mesh of every level. */
|
|
71
|
+
get meshes(): Mesh[];
|
|
72
|
+
/**
|
|
73
|
+
* The GPU buffers in use: the tree data by slot (`TREE_VEC4S` vec4 per slot), the level lists and
|
|
74
|
+
* their cross-fades (`LEVEL_COUNT` × capacity), the level counters and the draw arguments. The first
|
|
75
|
+
* three are replaced when the Variant grows; the counters and the draw arguments are kept.
|
|
76
|
+
*/
|
|
77
|
+
get buffers(): {
|
|
78
|
+
trees: StorageBufferAttribute;
|
|
79
|
+
lists: StorageBufferAttribute;
|
|
80
|
+
dithers: StorageBufferAttribute;
|
|
81
|
+
counters: StorageBufferAttribute;
|
|
82
|
+
args: IndirectStorageBufferAttribute;
|
|
83
|
+
};
|
|
84
|
+
/** The indirect draw arguments, LEVEL_COUNT × MAX_LEVEL_PARTS draws of 5 u32 (for read-back). */
|
|
85
|
+
get drawArguments(): IndirectStorageBufferAttribute;
|
|
86
|
+
/**
|
|
87
|
+
* How many trees each Detail Level drew in the last selection (indexed by DetailLevel; a tree in a
|
|
88
|
+
* cross-fade counts at both levels), read back from the draw arguments on the GPU.
|
|
89
|
+
*/
|
|
90
|
+
drawnCounts(renderer: Renderer): Promise<number[]>;
|
|
91
|
+
/**
|
|
92
|
+
* Gives `level` its meshes (at most MAX_LEVEL_PARTS parts), one per part, each drawn
|
|
93
|
+
* indirectly from the level's list. A part without indices (e.g. the leaves of a bare
|
|
94
|
+
* Definition) gets no mesh: WebGPU would draw it with an index count of 0. Returns the meshes;
|
|
95
|
+
* the caller adds them to the scene.
|
|
96
|
+
*/
|
|
97
|
+
setLevel(level: DetailLevel, parts: readonly LevelPart[]): Mesh[];
|
|
98
|
+
/**
|
|
99
|
+
* Writes one tree: `instance` = its INSTANCE_STRIDE floats of instance data (rotation, state),
|
|
100
|
+
* `position` = its base in forest space.
|
|
101
|
+
*/
|
|
102
|
+
write(slot: number, instance: ArrayLike<number>, position: readonly [number, number, number]): void;
|
|
103
|
+
/** Room for `capacity` trees (the tree data is kept; the lists are refilled every frame). */
|
|
104
|
+
resize(capacity: number): void;
|
|
105
|
+
/** Frees the meshes' geometry, the buffers and the compute pass (the materials belong to the Variant). */
|
|
106
|
+
dispose(): void;
|
|
107
|
+
private disposeBuffers;
|
|
108
|
+
/**
|
|
109
|
+
* The compute pass: reset the level counters; sort every tree into its level list (and, in a
|
|
110
|
+
* cross-fade, the next level's too), mirroring `selectDetailLevel`; copy the counts into the draw
|
|
111
|
+
* arguments of every level's meshes.
|
|
112
|
+
*/
|
|
113
|
+
private createDispatches;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Picks the level camera (the camera whose distance picks every tree's Detail Level) and runs every
|
|
117
|
+
* Variant's level selection before a Detail Level mesh of the Forest is drawn: once per frame (`renderer.info.frame`), and again in the same frame only when
|
|
118
|
+
* something it depends on changed (trees, settings, the level camera's or the Forest's position). So
|
|
119
|
+
* every render of a frame (shadow passes, other cameras) draws the levels of the frame's level camera.
|
|
120
|
+
*/
|
|
121
|
+
export declare class LevelSelection {
|
|
122
|
+
private readonly uniforms;
|
|
123
|
+
private frame;
|
|
124
|
+
/** The level camera of the current frame. */
|
|
125
|
+
private camera;
|
|
126
|
+
/** The last non-shadow camera seen drawing the Forest (before the first selection). */
|
|
127
|
+
private seen;
|
|
128
|
+
/** What the last selection was made from (see `inputs`). */
|
|
129
|
+
private last;
|
|
130
|
+
private readonly position;
|
|
131
|
+
constructor(uniforms: DetailLevelUniforms);
|
|
132
|
+
/** Notes the camera of a render that draws the Forest, unless it is a shadow pass. */
|
|
133
|
+
observe(scene: Scene | null, camera: Camera | null): void;
|
|
134
|
+
/**
|
|
135
|
+
* Called before a Detail Level mesh is drawn. The first call of a frame fixes the frame's level
|
|
136
|
+
* camera: `explicit` (`lod.camera`) when set, otherwise the camera of this render. A shadow map can
|
|
137
|
+
* be drawn before the camera's own render reaches the Forest: then it is the previous frame's level
|
|
138
|
+
* camera (or, on the first frame, the last camera seen drawing the Forest).
|
|
139
|
+
*/
|
|
140
|
+
prepare(renderer: Renderer, scene: Scene | null, camera: Camera | null, explicit: Camera | null, forest: Object3D, variants: readonly VariantLevels[]): void;
|
|
141
|
+
/** Everything the selection reads (leaves the camera's world position in `this.position`). */
|
|
142
|
+
private inputs;
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=levels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"levels.d.ts","sourceRoot":"","sources":["../../src/forest/levels.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,cAAc,EACd,8BAA8B,EAC9B,OAAO,EACP,IAAI,EACJ,sBAAsB,EACtB,OAAO,EACP,KAAK,MAAM,EACX,KAAK,WAAW,EAChB,KAAK,QAAQ,EAEb,KAAK,QAAQ,EACb,KAAK,QAAQ,EACb,KAAK,KAAK,EAEV,KAAK,WAAW,EACjB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,WAAW,EAA8B,MAAM,OAAO,CAAC;AAGhE,oHAAoH;AACpH,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,iFAAiF;AACjF,eAAO,MAAM,eAAe,IAAI,CAAC;AAMjC,kFAAkF;AAClF,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACpC,QAAQ,EAAE,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACvC,IAAI,EAAE,WAAW,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;IACnC,qEAAqE;IACrE,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC,sEAAsE;IACtE,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACrC;;;OAGG;IACH,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE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O,CAAC,QAAQ,CAAC,QAAQ,CAAiB;gBAEb,QAAQ,EAAE,mBAAmB;IAE1D,sFAAsF;IACtF,OAAO,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAIzD;;;;;OAKG;IACH,OAAO,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,aAAa,EAAE,GAAG,IAAI;IAqB5J,8FAA8F;IAC9F,OAAO,CAAC,MAAM;CAcf"}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { Camera } from 'three/webgpu';
|
|
2
|
+
import type { TreeDefinitionInput } from '../definition';
|
|
3
|
+
/** A Forest tree's Detail Level (GLOSSARY): Full (as without Detail Levels), Light (fewer faces and leaves) or Impostor (one card). */
|
|
4
|
+
export declare const DetailLevel: {
|
|
5
|
+
readonly Full: 0;
|
|
6
|
+
readonly Light: 1;
|
|
7
|
+
readonly Impostor: 2;
|
|
8
|
+
};
|
|
9
|
+
export type DetailLevel = (typeof DetailLevel)[keyof typeof DetailLevel];
|
|
10
|
+
/** Resolution of a Variant's Impostor atlases. */
|
|
11
|
+
export interface ImpostorAtlasOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Directions per side (frames × frames pictures). They are hemi-octahedral: they cover the upper
|
|
14
|
+
* hemisphere only, from the horizon to straight above (a view from below uses the horizon frames).
|
|
15
|
+
* Default 12.
|
|
16
|
+
*/
|
|
17
|
+
frames?: number;
|
|
18
|
+
/** Atlas width and height in pixels. Default 2048. */
|
|
19
|
+
size?: number;
|
|
20
|
+
}
|
|
21
|
+
/** The Detail Levels of a Forest (`ForestOptions.lod`). */
|
|
22
|
+
export interface ForestLodOptions {
|
|
23
|
+
/** Camera distance (world units, divided by the tree's placement scale) from which a tree draws Light. */
|
|
24
|
+
light: number;
|
|
25
|
+
/** Camera distance (as `light`, at least `light`) from which a fully grown tree draws as an Impostor. */
|
|
26
|
+
impostor: number;
|
|
27
|
+
/** Width of the cross-fade band, as a fraction (0..1) of each switch distance, centred on it. Default 0.1. */
|
|
28
|
+
fade?: number;
|
|
29
|
+
/** Impostor atlas resolution. Default 12 × 12 directions at 2048². */
|
|
30
|
+
impostorAtlas?: ImpostorAtlasOptions;
|
|
31
|
+
/** Partial Definition merged over the automatic Light reduction of every Variant. */
|
|
32
|
+
lightDefinition?: Omit<TreeDefinitionInput, 'schemaVersion'>;
|
|
33
|
+
/** The camera whose distance picks every tree's level. Default: the first non-shadow camera that draws the Forest in a frame. */
|
|
34
|
+
camera?: Camera | null;
|
|
35
|
+
}
|
|
36
|
+
/** A Forest's current Detail Level settings (`forest.lod`), every default filled in. */
|
|
37
|
+
export interface ForestLodSettings {
|
|
38
|
+
light: number;
|
|
39
|
+
impostor: number;
|
|
40
|
+
fade: number;
|
|
41
|
+
impostorAtlas: Required<ImpostorAtlasOptions>;
|
|
42
|
+
lightDefinition: Omit<TreeDefinitionInput, 'schemaVersion'> | null;
|
|
43
|
+
/** null: the first non-shadow camera that draws the Forest in a frame. */
|
|
44
|
+
camera: Camera | null;
|
|
45
|
+
}
|
|
46
|
+
/** What `forest.lod = …` can change live (only uniforms are written: no rebuild, no recompile). */
|
|
47
|
+
export type ForestLodUpdate = Partial<Pick<ForestLodSettings, 'light' | 'impostor' | 'fade' | 'camera'>>;
|
|
48
|
+
/** The distances the level selection needs. */
|
|
49
|
+
export type DetailLevelDistances = Pick<ForestLodSettings, 'light' | 'impostor' | 'fade'>;
|
|
50
|
+
/** A tree's Detail Level and how far it has faded into the next one. */
|
|
51
|
+
export interface DetailLevelSelection {
|
|
52
|
+
/** The nearer level the tree draws at. */
|
|
53
|
+
level: DetailLevel;
|
|
54
|
+
/**
|
|
55
|
+
* 0..1: how far the tree is into the cross-fade towards `level + 1`. The tree draws at `level`
|
|
56
|
+
* with amount `1 - fade` and, when `fade > 0`, also at `level + 1` with amount `fade`.
|
|
57
|
+
*/
|
|
58
|
+
fade: number;
|
|
59
|
+
}
|
|
60
|
+
export declare const DEFAULT_LOD_FADE = 0.1;
|
|
61
|
+
export declare const DEFAULT_IMPOSTOR_ATLAS: Required<ImpostorAtlasOptions>;
|
|
62
|
+
/** `lod: true`: Light from this many trunk heights away, Impostor from … */
|
|
63
|
+
export declare const DEFAULT_LIGHT_HEIGHTS = 6;
|
|
64
|
+
/** … this many trunk heights away. */
|
|
65
|
+
export declare const DEFAULT_IMPOSTOR_HEIGHTS = 20;
|
|
66
|
+
/** Smallest placement scale the selection divides by (a scale of 0 must not divide by zero). */
|
|
67
|
+
export declare const MIN_LOD_SCALE = 0.000001;
|
|
68
|
+
/**
|
|
69
|
+
* Picks a Forest tree's Detail Level. The single source of truth for level selection: the GPU
|
|
70
|
+
* compute pass mirrors it line by line.
|
|
71
|
+
*
|
|
72
|
+
* - `t = distance / max(scale, 1e-6)`: a tree at placement scale 2 switches at twice the distance.
|
|
73
|
+
* - Each switch distance `d` (`light`, `impostor`) has a cross-fade band from `d·(1 − fade/2)` to
|
|
74
|
+
* `d·(1 + fade/2)`; inside it the tree fades linearly from the nearer level to the next one.
|
|
75
|
+
* - A tree whose drawn Growth is below 1 is never an Impostor: it is capped at Light.
|
|
76
|
+
* - The Impostor switch is checked first, so if the two bands overlap the farther one wins.
|
|
77
|
+
*
|
|
78
|
+
* @param distance distance from the camera that picks the levels to the tree's base, world units
|
|
79
|
+
* @param scale the tree's placement scale
|
|
80
|
+
* @param growth the tree's drawn Growth (after its Growth delay)
|
|
81
|
+
*/
|
|
82
|
+
export declare function selectDetailLevel(distance: number, scale: number, growth: number, settings: DetailLevelDistances): DetailLevelSelection;
|
|
83
|
+
/** Throws a RangeError unless the distances and fade are valid. */
|
|
84
|
+
export declare function checkDetailLevelDistances({ light, impostor, fade }: DetailLevelDistances): void;
|
|
85
|
+
/** The switch distances of `lod: true`, from the tallest Variant's trunk height. */
|
|
86
|
+
export declare function defaultDetailLevelDistances(trunkHeight: number): Pick<ForestLodSettings, 'light' | 'impostor'>;
|
|
87
|
+
/**
|
|
88
|
+
* The settings of `ForestOptions.lod` with every default filled in, or null when it is missing or
|
|
89
|
+
* false. `trunkHeight` (the tallest Variant's) gives the distances of `lod: true`. Throws a RangeError
|
|
90
|
+
* for invalid settings.
|
|
91
|
+
*/
|
|
92
|
+
export declare function resolveForestLod(lod: boolean | ForestLodOptions | undefined, trunkHeight: number): ForestLodSettings | null;
|
|
93
|
+
/** Side of the ordered-dither (Bayer) matrix the cross-fade uses. */
|
|
94
|
+
export declare const DITHER_SIZE = 8;
|
|
95
|
+
/**
|
|
96
|
+
* The cross-fade threshold of screen pixel (x, y), in 0..1: an 8 × 8 Bayer matrix, the same in every
|
|
97
|
+
* frame (no temporal noise), so a still frame is deterministic. The GPU mirrors it bit for bit.
|
|
98
|
+
*/
|
|
99
|
+
export declare function ditherThreshold(x: number, y: number): number;
|
|
100
|
+
/**
|
|
101
|
+
* Whether a tree drawn at a level shows a pixel with dither `threshold`. A tree at `level` with
|
|
102
|
+
* `fade` shows the nearer level where `threshold < 1 − fade` and the next level (`next`) everywhere
|
|
103
|
+
* else, so the two levels together cover every pixel exactly once.
|
|
104
|
+
*/
|
|
105
|
+
export declare function showsPixel(fade: number, next: boolean, threshold: number): boolean;
|
|
106
|
+
//# sourceMappingURL=lod.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lod.d.ts","sourceRoot":"","sources":["../../src/forest/lod.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAEzD,uIAAuI;AACvI,eAAO,MAAM,WAAW;;;;CAA8C,CAAC;AACvE,MAAM,MAAM,WAAW,GAAG,CAAC,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
|
|
1
1
|
import type { Node } from 'three/webgpu';
|
|
2
|
-
import { type WindResponse, type WindSource } from '../wind';
|
|
2
|
+
import { type WindBurstFrame, type WindResponse, type WindSource } from '../wind';
|
|
3
3
|
/**
|
|
4
4
|
* Per-instance data of a Forest (one interleaved instanced buffer, 8 floats per tree):
|
|
5
5
|
* `iRotation` = the tree's rotation as a quaternion (x, y, z, w);
|
|
@@ -10,6 +10,24 @@ export declare const INSTANCE_ATTRIBUTES: {
|
|
|
10
10
|
readonly iRotation: 0;
|
|
11
11
|
readonly iState: 4;
|
|
12
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* What a mesh that draws one Detail Level of a Variant (ADR 0010) reads instead of the instanced
|
|
15
|
+
* attributes: the tree's data by slot, the slot coming from the level list at `instanceIndex`.
|
|
16
|
+
*/
|
|
17
|
+
export interface LevelInstance {
|
|
18
|
+
/** The tree's slot in the Variant (`uint`). */
|
|
19
|
+
slot: Node<'uint'>;
|
|
20
|
+
/** As `iRotation`. */
|
|
21
|
+
rotation: Node<'vec4'>;
|
|
22
|
+
/** As `iState`. */
|
|
23
|
+
state: Node<'vec4'>;
|
|
24
|
+
/** The tree's base in forest space. */
|
|
25
|
+
position: Node<'vec3'>;
|
|
26
|
+
/** The tree's cross-fade mask at this level (`bool`: draw this fragment), see `levelDither`. */
|
|
27
|
+
visible: Node<'bool'>;
|
|
28
|
+
}
|
|
29
|
+
/** @internal Marks `mesh` as drawing a Detail Level: every Forest node built for it reads `instance`. */
|
|
30
|
+
export declare function drawsDetailLevel(mesh: object, instance: LevelInstance): void;
|
|
13
31
|
/** Per-tree values in the instanced Season/Growth/Wind slots. */
|
|
14
32
|
export declare function instanceState(): {
|
|
15
33
|
scale: Node<'float'>;
|
|
@@ -17,8 +35,31 @@ export declare function instanceState(): {
|
|
|
17
35
|
season: Node<'float'>;
|
|
18
36
|
windPhase: Node<'float'>;
|
|
19
37
|
};
|
|
38
|
+
/** The tree's slot in its Variant (`uint`): the instance index on the instanced meshes, from the level list on a Detail Level mesh. */
|
|
39
|
+
export declare function instanceSlot(): Node<'uint'>;
|
|
40
|
+
/** Whether to draw this fragment: the Detail Level cross-fade (always true on the instanced meshes). */
|
|
41
|
+
export declare function levelVisible(): Node<'bool'>;
|
|
42
|
+
/**
|
|
43
|
+
* The tree's base in forest space, on a Detail Level mesh (the Impostor card places itself from it).
|
|
44
|
+
* Throws when built for any other object: the instanced meshes get their position from three.js.
|
|
45
|
+
*/
|
|
46
|
+
export declare function levelTreePosition(): Node<'vec3'>;
|
|
47
|
+
/**
|
|
48
|
+
* The tree's base in forest space, on the instanced meshes and the Detail Level meshes alike, as the
|
|
49
|
+
* vertex stage knows it before `positionNode` runs. On an InstancedMesh three.js only hands over the
|
|
50
|
+
* placed vertex (M·p), so the base is M·p − R·s·p, kept in a variable so that it is worked out before
|
|
51
|
+
* `positionNode` replaces `positionLocal`; on a Detail Level mesh it is the tree's data.
|
|
52
|
+
*/
|
|
53
|
+
export declare function instanceTreeBase(): Node<'vec3'>;
|
|
54
|
+
/** Rotates `v` by the quaternion `q` (`inverse` = by its conjugate). */
|
|
55
|
+
export declare function rotateByQuaternion(q: Node<'vec4'>, v: Node<'vec3'>, inverse?: boolean): Node<'vec3'>;
|
|
20
56
|
/** Rotates `v` by the instance quaternion (`inverse` = by its conjugate): tree space to forest space. */
|
|
21
57
|
export declare function instanceRotate(v: Node<'vec3'>, inverse?: boolean): Node<'vec3'>;
|
|
58
|
+
/**
|
|
59
|
+
* Where a Wind Burst finds a Forest tree: its own base (through the Forest's transform) and its own
|
|
60
|
+
* rotation, so each instance bends away from the burst point like a single Tree does.
|
|
61
|
+
*/
|
|
62
|
+
export declare function instanceBurstFrame(): WindBurstFrame;
|
|
22
63
|
/**
|
|
23
64
|
* The vertex position of a Forest tree (positionNode of an instanced Variant mesh).
|
|
24
65
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodes.d.ts","sourceRoot":"","sources":["../../src/forest/nodes.ts"],"names":[],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ACH,wBAAgB,iBAAiB,IAAI,IAAI,CAAC,MAAM,CAAC,CAOhD;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAAC,MAAM,CAAC,CAK/C;AAED,wEAAwE;AACxE,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,OAAO,UAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,CAIlG;AAED,yGAAyG;AACzG,wBAAgB,cAAc,CAAC,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,OAAO,UAAQ,GAAG,IAAI,CAAC,MAAM,CAAC,CAE7E;AAiBD;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,cAAc,CAMnD;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,YAAY,EAAE,IAAI,GAAE,IAAI,CAAC,MAAM,CAAoB,GAAG,IAAI,CAAC,MAAM,CAAC,CAkB5H"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export type Vec3 = readonly [number, number, number];
|
|
2
|
+
/** A frame's camera: it looks along -forward, with `right` and `up` across its picture (right × up = forward). */
|
|
3
|
+
export interface FrameBasis {
|
|
4
|
+
right: Vec3;
|
|
5
|
+
up: Vec3;
|
|
6
|
+
forward: Vec3;
|
|
7
|
+
}
|
|
8
|
+
/** The (up to) four frames a view blends, with their weights (they sum to 1). */
|
|
9
|
+
export interface FrameBlend {
|
|
10
|
+
frames: [number, number][];
|
|
11
|
+
weights: number[];
|
|
12
|
+
}
|
|
13
|
+
/** A view direction (from the tree towards the viewer) on the unit square; views from below count as from the horizon. */
|
|
14
|
+
export declare function octahedralEncode(direction: Vec3): [number, number];
|
|
15
|
+
/** The unit direction at a point of the unit square (inverse of `octahedralEncode`). */
|
|
16
|
+
export declare function octahedralDecode(u: number, v: number): Vec3;
|
|
17
|
+
/** The direction frame (i, j) pictures the tree from. */
|
|
18
|
+
export declare function frameDirection(i: number, j: number, frames: number): Vec3;
|
|
19
|
+
/** The camera basis of a frame looking at the tree from `forward`. */
|
|
20
|
+
export declare function frameBasis(forward: Vec3): FrameBasis;
|
|
21
|
+
/**
|
|
22
|
+
* The four frames around a view direction and their bilinear weights, in the order (i, j), (i+1, j),
|
|
23
|
+
* (i, j+1), (i+1, j+1). On the grid's edge (and with one frame) the frames are clamped to the grid.
|
|
24
|
+
*/
|
|
25
|
+
export declare function blendFrames(view: Vec3, frames: number): FrameBlend;
|
|
26
|
+
/**
|
|
27
|
+
* Where frame `forward` pictured what is seen through `point` of the card (tree space, relative to
|
|
28
|
+
* the tree's centre) looking along `-view`: the line of sight meets the frame's plane (through the
|
|
29
|
+
* centre, facing `forward`) and that spot is projected onto the frame. In 0..1 across the frame,
|
|
30
|
+
* whose picture spans `2 · half` (the card's size).
|
|
31
|
+
*/
|
|
32
|
+
export declare function frameUv(point: Vec3, view: Vec3, forward: Vec3, half: number): [number, number];
|
|
33
|
+
//# sourceMappingURL=octahedral.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"octahedral.d.ts","sourceRoot":"","sources":["../../src/forest/octahedral.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,IAAI,GAAG,SAAS,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC;AAErD,kHAAkH;AAClH,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,IAAI,CAAC;IACZ,EAAE,EAAE,IAAI,CAAC;IACT,OAAO,EAAE,IAAI,CAAC;CACf;AAED,iFAAiF;AACjF,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IAC3B,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAqBD,0HAA0H;AAC1H,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAMlE;AAED,wFAAwF;AACxF,wBAAgB,gBAAgB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAM3D;AAED,yDAAyD;AACzD,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAEzE;AAED,sEAAsE;AACtE,wBAAgB,UAAU,CAAC,OAAO,EAAE,IAAI,GAAG,UAAU,CAIpD;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CAelE;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAK9F"}
|