@casmo/tree.js 0.2.0 → 0.4.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 +392 -1
- package/dist/{apply-CcodnAbs.js → apply-Cio2t7CZ.js} +51 -16
- package/dist/apply-Cio2t7CZ.js.map +1 -0
- package/dist/bake/index.d.ts +43 -4
- package/dist/bake/index.d.ts.map +1 -1
- package/dist/definition/defaults.d.ts +9 -1
- package/dist/definition/defaults.d.ts.map +1 -1
- package/dist/definition/index.d.ts +2 -2
- package/dist/definition/index.d.ts.map +1 -1
- package/dist/definition/schema.d.ts.map +1 -1
- package/dist/definition/types.d.ts +86 -0
- package/dist/definition/types.d.ts.map +1 -1
- package/dist/effects/effects.d.ts +51 -6
- package/dist/effects/effects.d.ts.map +1 -1
- package/dist/effects/glow.d.ts +5 -0
- package/dist/effects/glow.d.ts.map +1 -1
- package/dist/effects/grade.d.ts +3 -0
- package/dist/effects/grade.d.ts.map +1 -1
- package/dist/effects/highlight.d.ts +35 -0
- package/dist/effects/highlight.d.ts.map +1 -0
- package/dist/effects/index.d.ts +5 -1
- package/dist/effects/index.d.ts.map +1 -1
- package/dist/effects/inner-lines.d.ts +39 -0
- package/dist/effects/inner-lines.d.ts.map +1 -0
- package/dist/effects/live.d.ts +12 -0
- package/dist/effects/live.d.ts.map +1 -0
- package/dist/effects/mask.d.ts +23 -11
- package/dist/effects/mask.d.ts.map +1 -1
- package/dist/effects/outline.d.ts +12 -0
- package/dist/effects/outline.d.ts.map +1 -1
- package/dist/effects/pass.d.ts +27 -0
- package/dist/effects/pass.d.ts.map +1 -0
- package/dist/effects/screen.d.ts +31 -0
- package/dist/effects/screen.d.ts.map +1 -0
- package/dist/effects/suggested.d.ts +5 -0
- package/dist/effects/suggested.d.ts.map +1 -1
- package/dist/effects/tree-id.d.ts +50 -0
- package/dist/effects/tree-id.d.ts.map +1 -0
- package/dist/effects.js +772 -57
- package/dist/effects.js.map +1 -1
- package/dist/forest/Forest.d.ts +29 -1
- package/dist/forest/Forest.d.ts.map +1 -1
- package/dist/forest/nodes.d.ts +2 -0
- package/dist/forest/nodes.d.ts.map +1 -1
- package/dist/{forest-DTrD8puH.js → forest-lg61rhKM.js} +1125 -191
- package/dist/forest-lg61rhKM.js.map +1 -0
- package/dist/generator/crown.d.ts +28 -0
- package/dist/generator/crown.d.ts.map +1 -0
- package/dist/generator/growth.d.ts +1 -1
- package/dist/generator/growth.d.ts.map +1 -1
- package/dist/generator/index.d.ts +2 -1
- package/dist/generator/index.d.ts.map +1 -1
- package/dist/generator/mesh.d.ts +10 -2
- package/dist/generator/mesh.d.ts.map +1 -1
- package/dist/generator/occlusion.d.ts +8 -0
- package/dist/generator/occlusion.d.ts.map +1 -0
- package/dist/generator/roots.d.ts +16 -0
- package/dist/generator/roots.d.ts.map +1 -0
- package/dist/generator/trunk.d.ts +8 -0
- package/dist/generator/trunk.d.ts.map +1 -1
- package/dist/generator/types.d.ts +27 -1
- package/dist/generator/types.d.ts.map +1 -1
- package/dist/growth/index.d.ts +1 -1
- package/dist/growth/index.d.ts.map +1 -1
- package/dist/growth/tsl.d.ts +2 -0
- package/dist/growth/tsl.d.ts.map +1 -1
- package/dist/index.d.ts +4 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +234 -28
- package/dist/index.js.map +1 -1
- package/dist/materials/crown-nodes.d.ts +20 -0
- package/dist/materials/crown-nodes.d.ts.map +1 -0
- package/dist/materials/crown-normals.d.ts +17 -0
- package/dist/materials/crown-normals.d.ts.map +1 -0
- package/dist/materials/ground-tint.d.ts +13 -0
- package/dist/materials/ground-tint.d.ts.map +1 -0
- package/dist/materials/index.d.ts +7 -1
- package/dist/materials/index.d.ts.map +1 -1
- package/dist/materials/leaf-translucency-model.d.ts +14 -0
- package/dist/materials/leaf-translucency-model.d.ts.map +1 -0
- package/dist/materials/leaf-translucency.d.ts +73 -0
- package/dist/materials/leaf-translucency.d.ts.map +1 -0
- package/dist/materials/material-features.d.ts +43 -0
- package/dist/materials/material-features.d.ts.map +1 -0
- package/dist/materials/occlusion.d.ts +10 -0
- package/dist/materials/occlusion.d.ts.map +1 -0
- package/dist/materials/toon.d.ts +18 -1
- package/dist/materials/toon.d.ts.map +1 -1
- package/dist/{names-C6-wuJ29.js → names-BE9he6CS.js} +133 -9
- package/dist/names-BE9he6CS.js.map +1 -0
- package/dist/react.js +1 -1
- package/dist/species/almond.js +12 -2
- package/dist/species/almond.json +10 -1
- package/dist/species/apple.js +12 -2
- package/dist/species/apple.json +10 -1
- package/dist/species/ash.js +12 -2
- package/dist/species/ash.json +10 -1
- package/dist/species/beech.js +12 -2
- package/dist/species/beech.json +10 -1
- package/dist/species/birch.js +12 -2
- package/dist/species/birch.json +10 -1
- package/dist/species/cedar.js +12 -2
- package/dist/species/cedar.json +10 -1
- package/dist/species/cherry.js +12 -2
- package/dist/species/cherry.json +10 -1
- package/dist/species/chestnut.js +12 -2
- package/dist/species/chestnut.json +10 -1
- package/dist/species/douglas-fir.js +12 -2
- package/dist/species/douglas-fir.json +10 -1
- package/dist/species/elm.js +12 -2
- package/dist/species/elm.json +10 -1
- package/dist/species/hemlock.js +12 -2
- package/dist/species/hemlock.json +10 -1
- package/dist/species/hickory.js +12 -2
- package/dist/species/hickory.json +10 -1
- package/dist/species/juniper.js +12 -2
- package/dist/species/juniper.json +10 -1
- package/dist/species/mahogany.js +12 -2
- package/dist/species/mahogany.json +10 -1
- package/dist/species/maple.js +12 -2
- package/dist/species/maple.json +10 -1
- package/dist/species/oak.js +12 -2
- package/dist/species/oak.json +10 -1
- package/dist/species/olive.js +12 -2
- package/dist/species/olive.json +10 -1
- package/dist/species/peach.js +12 -2
- package/dist/species/peach.json +10 -1
- package/dist/species/pear.js +12 -2
- package/dist/species/pear.json +10 -1
- package/dist/species/pine.js +12 -2
- package/dist/species/pine.json +10 -1
- package/dist/species/plum.js +12 -2
- package/dist/species/plum.json +10 -1
- package/dist/species/red-oak.js +12 -2
- package/dist/species/red-oak.json +10 -1
- package/dist/species/redwood.js +12 -2
- package/dist/species/redwood.json +10 -1
- package/dist/species/sequoia.js +12 -2
- package/dist/species/sequoia.json +10 -1
- package/dist/species/spruce.js +12 -2
- package/dist/species/spruce.json +10 -1
- package/dist/species/teak.js +12 -2
- package/dist/species/teak.json +10 -1
- package/dist/species/types.d.ts +7 -3
- package/dist/species/types.d.ts.map +1 -1
- package/dist/species/walnut.js +12 -2
- package/dist/species/walnut.json +10 -1
- package/dist/species/white-oak.js +12 -2
- package/dist/species/white-oak.json +10 -1
- package/dist/styles/apply.d.ts.map +1 -1
- package/dist/styles/low-poly.js +6 -4
- package/dist/styles/low-poly.js.map +1 -1
- package/dist/styles/material-features.d.ts +27 -0
- package/dist/styles/material-features.d.ts.map +1 -0
- package/dist/styles/realistic.js +6 -4
- package/dist/styles/realistic.js.map +1 -1
- package/dist/styles/stylized.js +6 -4
- package/dist/styles/stylized.js.map +1 -1
- package/dist/tree/Tree.d.ts +28 -1
- package/dist/tree/Tree.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/apply-CcodnAbs.js.map +0 -1
- package/dist/forest-DTrD8puH.js.map +0 -1
- package/dist/names-C6-wuJ29.js.map +0 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ColorRepresentation, type Node } from 'three/webgpu';
|
|
2
|
+
import type { LiveTreeEffect } from './live';
|
|
2
3
|
import type { TreeEffectInput } from './mask';
|
|
3
4
|
/** Tree outline settings. */
|
|
4
5
|
export interface TreeOutlineOptions {
|
|
@@ -8,11 +9,22 @@ export interface TreeOutlineOptions {
|
|
|
8
9
|
thickness?: number;
|
|
9
10
|
/** Opacity of the line, 0..1 (default 1). */
|
|
10
11
|
strength?: number;
|
|
12
|
+
/**
|
|
13
|
+
* Also draw the line between overlapping trees (Tree–Tree, Forest tree–Forest tree, Tree–Forest
|
|
14
|
+
* tree): on a selected tree pixel next to another tree that is further away, so the line lies on
|
|
15
|
+
* the front tree's side, as thick as the outer outline (with a standard, reversed or logarithmic
|
|
16
|
+
* depth buffer). Needs the `treeId` and `depth` inputs (see `treeEffectsPass`). Default false.
|
|
17
|
+
* Changing it builds a new graph.
|
|
18
|
+
*/
|
|
19
|
+
betweenTrees?: boolean;
|
|
11
20
|
}
|
|
12
21
|
/**
|
|
13
22
|
* Tree Effect: an outline along the silhouettes of the selected trees (the `selection` of the
|
|
14
23
|
* tree mask, see `createTreeMask`; all trees by default), around the outside of the canopy and
|
|
15
24
|
* the gaps in it. The line is drawn on the inside of the silhouette, so only tree pixels change.
|
|
25
|
+
* With `betweenTrees`, it is also drawn where a tree overlaps another one behind it.
|
|
16
26
|
*/
|
|
17
27
|
export declare function treeOutline(input: TreeEffectInput, options?: TreeOutlineOptions): Node<'vec4'>;
|
|
28
|
+
/** {@link treeOutline} with its settings as uniforms. */
|
|
29
|
+
export declare function liveTreeOutline(input: TreeEffectInput, options?: TreeOutlineOptions): LiveTreeEffect<TreeOutlineOptions>;
|
|
18
30
|
//# sourceMappingURL=outline.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"outline.d.ts","sourceRoot":"","sources":["../../src/effects/outline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,mBAAmB,EAAE,KAAK,IAAI,EAAE,MAAM,cAAc,CAAC;AAE1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"outline.d.ts","sourceRoot":"","sources":["../../src/effects/outline.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,mBAAmB,EAAE,KAAK,IAAI,EAAE,MAAM,cAAc,CAAC;AAE1E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAG9C,6BAA6B;AAC7B,MAAM,WAAW,kBAAkB;IACjC,gDAAgD;IAChD,KAAK,CAAC,EAAE,mBAAmB,CAAC;IAC5B,wCAAwC;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,GAAE,kBAAuB,GAAG,IAAI,CAAC,MAAM,CAAC,CAElG;AAED,yDAAyD;AACzD,wBAAgB,eAAe,CAAC,KAAK,EAAE,eAAe,EAAE,OAAO,GAAE,kBAAuB,GAAG,cAAc,CAAC,kBAAkB,CAAC,CAwB5H"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type Camera, type Object3D, type PassNode, type Scene } from 'three/webgpu';
|
|
2
|
+
import { type TreeEffectInput } from './mask';
|
|
3
|
+
/**
|
|
4
|
+
* The opt-in extra channels of a scene pass, next to the colour and the tree mask (which are always
|
|
5
|
+
* there). Each one adds an MRT target, so leave them off unless an effect (or picking) needs them.
|
|
6
|
+
*/
|
|
7
|
+
export interface TreeEffectsChannels {
|
|
8
|
+
/**
|
|
9
|
+
* The Tree ID target (`treeIdMRT`), for effects that tell trees apart and for picking. Turns MSAA
|
|
10
|
+
* off on the scene pass (see `treeIdTexture`).
|
|
11
|
+
*/
|
|
12
|
+
treeId?: boolean;
|
|
13
|
+
/** The view normal target (`treeNormalMRT`, RGBA8, the 'color' encoding), for Inner Lines. */
|
|
14
|
+
normal?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/** A scene pass that renders the colour, the tree mask and the chosen channels, ready for the Tree Effects. */
|
|
17
|
+
export interface TreeEffectsPass extends TreeEffectInput {
|
|
18
|
+
pass: PassNode;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Creates `pass(scene, camera)` with MRT `{ output, treeMask }` (plus the opt-in `channels`, e.g.
|
|
22
|
+
* `{ treeId: true }`, `{ normal: true }`) and returns it with the texture nodes of every target (and the depth and camera) as the effects' inputs.
|
|
23
|
+
* `selection`: the trees to outline (default `null` = all trees), see `createTreeMask`. If your
|
|
24
|
+
* pipeline already has a scene pass, merge `treeMaskMRT` (and `treeIdMRT`) into it instead.
|
|
25
|
+
*/
|
|
26
|
+
export declare function treeEffectsPass(scene: Scene, camera: Camera, selection?: readonly Object3D[] | null, channels?: TreeEffectsChannels): TreeEffectsPass;
|
|
27
|
+
//# sourceMappingURL=pass.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pass.d.ts","sourceRoot":"","sources":["../../src/effects/pass.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,KAAK,MAAM,EAAE,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAE,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;AAEvG,OAAO,EAA0B,KAAK,eAAe,EAAE,MAAM,QAAQ,CAAC;AAItE;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,8FAA8F;IAC9F,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,+GAA+G;AAC/G,MAAM,WAAW,eAAgB,SAAQ,eAAe;IACtD,IAAI,EAAE,QAAQ,CAAC;CAChB;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,SAAS,GAAE,SAAS,QAAQ,EAAE,GAAG,IAAW,EAC5C,QAAQ,GAAE,mBAAwB,GACjC,eAAe,CAwBjB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Camera, Node, TextureNode } from 'three/webgpu';
|
|
2
|
+
/** Eight sample directions around a pixel, unit length: the four axes and the four diagonals. */
|
|
3
|
+
export declare const EIGHT_DIRECTIONS: readonly (readonly [number, number])[];
|
|
4
|
+
/** Four sample directions around a pixel: the axes. */
|
|
5
|
+
export declare const FOUR_DIRECTIONS: readonly (readonly [number, number])[];
|
|
6
|
+
/** The size of a texture in pixels, as a `vec2`. */
|
|
7
|
+
export declare function sizeOf(texture: TextureNode): Node<'vec2'>;
|
|
8
|
+
/**
|
|
9
|
+
* The texel `offset` px from the pixel being shaded, clamped to the texture, for exact texel loads
|
|
10
|
+
* (`texture.load(texelAt(texture, offset))`) of unfiltered targets such as the Tree ID.
|
|
11
|
+
*/
|
|
12
|
+
export declare function texelAt(texture: TextureNode, offset: Node<'vec2'>): Node<'ivec2'>;
|
|
13
|
+
/** The Tree ID at a texel (see {@link texelAt}): 0 where no tree is drawn. */
|
|
14
|
+
export declare function treeIdAt(treeId: TextureNode, texel: Node<'ivec2'>): Node<'uint'>;
|
|
15
|
+
/** An optional input an effect needs, or an error naming the effect, the input and where to get it. */
|
|
16
|
+
export declare function requireInput<T>(effect: string, value: T | undefined, name: string, hint: string): T;
|
|
17
|
+
/**
|
|
18
|
+
* Whether the scene depth `depth` is further from the camera than `than` (both raw values of the
|
|
19
|
+
* scene pass's depth texture). Decided per renderer when the shader is built: a reversed depth
|
|
20
|
+
* buffer (`reversedDepthBuffer`) stores 1 at the near plane and 0 at the far plane, a standard or
|
|
21
|
+
* logarithmic one the other way around.
|
|
22
|
+
*/
|
|
23
|
+
export declare const isFurther: (depth: Node<"float">, than: Node<"float">) => Node<"bool">;
|
|
24
|
+
/**
|
|
25
|
+
* A function turning a raw value of the scene pass's depth texture into view Z (negative, in world
|
|
26
|
+
* units) for `camera` (its near and far are read every render). It follows the renderer's depth
|
|
27
|
+
* buffer: standard, reversed (`reversedDepthBuffer`) or logarithmic (`logarithmicDepthBuffer`,
|
|
28
|
+
* which three only applies to perspective cameras).
|
|
29
|
+
*/
|
|
30
|
+
export declare function viewZFromDepth(camera: Camera): (depth: Node<'float'>) => Node<'float'>;
|
|
31
|
+
//# sourceMappingURL=screen.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screen.d.ts","sourceRoot":"","sources":["../../src/effects/screen.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,IAAI,EAAe,WAAW,EAAE,MAAM,cAAc,CAAC;AAI3E,iGAAiG;AACjG,eAAO,MAAM,gBAAgB,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAGlE,CAAC;AACF,uDAAuD;AACvD,eAAO,MAAM,eAAe,EAAE,SAAS,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAAuC,CAAC;AAE1G,oDAAoD;AACpD,wBAAgB,MAAM,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,CAEzD;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,CAEjF;AAED,8EAA8E;AAC9E,wBAAgB,QAAQ,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC,CAEhF;AAED,uGAAuG;AACvG,wBAAgB,YAAY,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,CAGnG;AAED;;;;;GAKG;AACH,eAAO,MAAM,SAAS,EAEN,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,MAAM,CAAC,CAAC;AAE5E;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,CAAC,KAAK,EAAE,IAAI,CAAC,OAAO,CAAC,KAAK,IAAI,CAAC,OAAO,CAAC,CAkBtF"}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import type { StyleName } from '../styles/registry';
|
|
2
2
|
import type { TreeColorGradeOptions } from './grade';
|
|
3
3
|
import type { LeafGlowOptions } from './glow';
|
|
4
|
+
import type { TreeHighlightOptions } from './highlight';
|
|
4
5
|
import type { TreeOutlineOptions } from './outline';
|
|
6
|
+
import type { InnerLinesOptions } from './inner-lines';
|
|
5
7
|
/** A combination of Tree Effects; leave an effect out to skip it. `{}` = no effects. */
|
|
6
8
|
export interface TreeEffectsSettings {
|
|
7
9
|
grade?: TreeColorGradeOptions;
|
|
8
10
|
glow?: LeafGlowOptions;
|
|
9
11
|
outline?: TreeOutlineOptions;
|
|
12
|
+
innerLines?: InnerLinesOptions;
|
|
13
|
+
/** Marks the TreeEffects' `highlighted` trees; never in a suggestion. */
|
|
14
|
+
highlight?: TreeHighlightOptions;
|
|
10
15
|
}
|
|
11
16
|
/** The suggested combination of Tree Effects for each built-in Style. */
|
|
12
17
|
export declare const SUGGESTED_TREE_EFFECTS: Record<StyleName, TreeEffectsSettings>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"suggested.d.ts","sourceRoot":"","sources":["../../src/effects/suggested.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"suggested.d.ts","sourceRoot":"","sources":["../../src/effects/suggested.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACrD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAEvD,wFAAwF;AACxF,MAAM,WAAW,mBAAmB;IAClC,KAAK,CAAC,EAAE,qBAAqB,CAAC;IAC9B,IAAI,CAAC,EAAE,eAAe,CAAC;IACvB,OAAO,CAAC,EAAE,kBAAkB,CAAC;IAC7B,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,yEAAyE;IACzE,SAAS,CAAC,EAAE,oBAAoB,CAAC;CAClC;AAED,yEAAyE;AACzE,eAAO,MAAM,sBAAsB,EAAE,MAAM,CAAC,SAAS,EAAE,mBAAmB,CAqBzE,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type MRTNode, type PassNode, type Renderer, type Texture } from 'three/webgpu';
|
|
2
|
+
import type { ForestTree } from '../forest';
|
|
3
|
+
import type { Tree } from '../tree';
|
|
4
|
+
/** Name of the Tree ID output in a pass's MRT (`scenePass.getTextureNode(TREE_ID)`), see {@link treeIdMRT}. */
|
|
5
|
+
export declare const TREE_ID = "treeId";
|
|
6
|
+
/**
|
|
7
|
+
* The current Tree ID of a Tree or a Forest tree, or `undefined` for a Forest tree that was removed.
|
|
8
|
+
* IDs are handed out lazily, on first use: by this function or by the first draw with the Tree ID
|
|
9
|
+
* channel, whichever comes first. So asking for a Tree's ID before it is drawn reserves it then
|
|
10
|
+
* (and for a Forest tree the block of its Variant's current meshes). A Forest tree's ID is
|
|
11
|
+
* frame-relative (see {@link treeFromId}).
|
|
12
|
+
*/
|
|
13
|
+
export declare function treeIdOf(tree: Tree | ForestTree): number | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* The Tree or Forest tree with this Tree ID, resolved against the current trees, or `undefined`
|
|
16
|
+
* for 0 (not a tree), an unknown ID or a tree that is gone.
|
|
17
|
+
*/
|
|
18
|
+
export declare function treeFromId(id: number): Tree | ForestTree | undefined;
|
|
19
|
+
/**
|
|
20
|
+
* The MRT output that renders each tree's Tree ID ({@link createTreeId}) next to the colour, opt-in
|
|
21
|
+
* next to {@link treeMaskMRT}. Merge it into the MRT of your own scene pass and always call
|
|
22
|
+
* {@link treeIdTexture} on that pass afterwards:
|
|
23
|
+
* `scenePass.setMRT(mrt({ output }).merge(treeMaskMRT()).merge(treeIdMRT())); treeIdTexture(scenePass);`.
|
|
24
|
+
* Note that this turns MSAA off on that scene pass (an integer target cannot be multisampled, see
|
|
25
|
+
* {@link treeIdTexture}). Read IDs back with {@link readTreeId}, or in a shader with exact texel
|
|
26
|
+
* loads (never filtered).
|
|
27
|
+
*/
|
|
28
|
+
export declare function treeIdMRT(): MRTNode;
|
|
29
|
+
/**
|
|
30
|
+
* Makes the Tree ID target of a scene pass ({@link treeIdMRT} merged into its MRT) one 32-bit
|
|
31
|
+
* unsigned integer per pixel (`r32uint`, read without filtering) and returns its texture. Call it
|
|
32
|
+
* once after `setMRT`, before the first render.
|
|
33
|
+
*
|
|
34
|
+
* **MSAA is turned off on this scene pass**: an integer target cannot be multisampled, and all the
|
|
35
|
+
* targets of a pass share one sample count, so this sets `scenePass.options.samples = 0`, also with
|
|
36
|
+
* an `antialias: true` renderer (the colour then has aliased edges unless you add FXAA/SMAA after
|
|
37
|
+
* the pass). That is a hard constraint of WebGPU and WebGL2, not a choice of tree.js.
|
|
38
|
+
*
|
|
39
|
+
* On the WebGL2 fallback it also makes the pass clear the Tree ID target to 0 right before every
|
|
40
|
+
* render (three cannot clear integer targets there), so a pixel where nothing is drawn reads 0.
|
|
41
|
+
*/
|
|
42
|
+
export declare function treeIdTexture(scenePass: PassNode): Texture;
|
|
43
|
+
/**
|
|
44
|
+
* Reads the Tree ID under a point of the canvas from the last render of `scenePass` (with
|
|
45
|
+
* {@link treeIdMRT} in its MRT): `x`, `y` in CSS pixels from the canvas's top left corner, as in
|
|
46
|
+
* `event.offsetX/offsetY`. Resolves to 0 off the canvas or where no tree is drawn. Resolve the ID
|
|
47
|
+
* with {@link treeFromId} right away: IDs are frame-relative.
|
|
48
|
+
*/
|
|
49
|
+
export declare function readTreeId(renderer: Renderer, scenePass: PassNode, x: number, y: number): Promise<number>;
|
|
50
|
+
//# sourceMappingURL=tree-id.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tree-id.d.ts","sourceRoot":"","sources":["../../src/effects/tree-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiG,KAAK,OAAO,EAA4B,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAE,KAAK,OAAO,EAAE,MAAM,cAAc,CAAC;AAEjN,OAAO,KAAK,EAAU,UAAU,EAAiB,MAAM,WAAW,CAAC;AACnE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAGpC,+GAA+G;AAC/G,eAAO,MAAM,OAAO,WAAW,CAAC;AA0EhC;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,IAAI,GAAG,UAAU,GAAG,MAAM,GAAG,SAAS,CAKpE;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,GAAG,UAAU,GAAG,SAAS,CAQpE;AAiHD;;;;;;;;GAQG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAInC;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,QAAQ,GAAG,OAAO,CAU1D;AAED;;;;;GAKG;AACH,wBAAsB,UAAU,CAAC,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAa/G"}
|