@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.
Files changed (135) hide show
  1. package/README.md +590 -4
  2. package/dist/effects/custom.d.ts +62 -0
  3. package/dist/effects/custom.d.ts.map +1 -0
  4. package/dist/effects/effects.d.ts +42 -1
  5. package/dist/effects/effects.d.ts.map +1 -1
  6. package/dist/effects/index.d.ts +2 -0
  7. package/dist/effects/index.d.ts.map +1 -1
  8. package/dist/effects/mask.d.ts +9 -1
  9. package/dist/effects/mask.d.ts.map +1 -1
  10. package/dist/effects/tree-id.d.ts.map +1 -1
  11. package/dist/effects-qHx_8Dlk.js +1052 -0
  12. package/dist/effects-qHx_8Dlk.js.map +1 -0
  13. package/dist/effects.js +2 -963
  14. package/dist/forest/Forest.d.ts +80 -4
  15. package/dist/forest/Forest.d.ts.map +1 -1
  16. package/dist/forest/forest-lod.d.ts +70 -0
  17. package/dist/forest/forest-lod.d.ts.map +1 -0
  18. package/dist/forest/impostor-material.d.ts +106 -0
  19. package/dist/forest/impostor-material.d.ts.map +1 -0
  20. package/dist/forest/impostor-season.d.ts +13 -0
  21. package/dist/forest/impostor-season.d.ts.map +1 -0
  22. package/dist/forest/impostor.d.ts +105 -0
  23. package/dist/forest/impostor.d.ts.map +1 -0
  24. package/dist/forest/index.d.ts +1 -0
  25. package/dist/forest/index.d.ts.map +1 -1
  26. package/dist/forest/levels.d.ts +144 -0
  27. package/dist/forest/levels.d.ts.map +1 -0
  28. package/dist/forest/lod.d.ts +106 -0
  29. package/dist/forest/lod.d.ts.map +1 -0
  30. package/dist/forest/nodes.d.ts +42 -1
  31. package/dist/forest/nodes.d.ts.map +1 -1
  32. package/dist/forest/octahedral.d.ts +33 -0
  33. package/dist/forest/octahedral.d.ts.map +1 -0
  34. package/dist/{forest-lg61rhKM.js → forest-CM5DrklM.js} +1723 -340
  35. package/dist/forest-CM5DrklM.js.map +1 -0
  36. package/dist/generator/fruit.d.ts +2 -0
  37. package/dist/generator/fruit.d.ts.map +1 -1
  38. package/dist/generator/index.d.ts +1 -0
  39. package/dist/generator/index.d.ts.map +1 -1
  40. package/dist/generator/light.d.ts +36 -0
  41. package/dist/generator/light.d.ts.map +1 -0
  42. package/dist/index.d.ts +3 -2
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js +5 -2
  45. package/dist/index.js.map +1 -1
  46. package/dist/materials/crown-nodes.d.ts +5 -0
  47. package/dist/materials/crown-nodes.d.ts.map +1 -1
  48. package/dist/materials/leaf-translucency-model.d.ts +6 -1
  49. package/dist/materials/leaf-translucency-model.d.ts.map +1 -1
  50. package/dist/materials/material-features.d.ts +12 -0
  51. package/dist/materials/material-features.d.ts.map +1 -1
  52. package/dist/materials/shader-hooks.d.ts +155 -0
  53. package/dist/materials/shader-hooks.d.ts.map +1 -0
  54. package/dist/motion-Qd7xjeZM.js +276 -0
  55. package/dist/motion-Qd7xjeZM.js.map +1 -0
  56. package/dist/nodes-DxgTyF9B.js +436 -0
  57. package/dist/nodes-DxgTyF9B.js.map +1 -0
  58. package/dist/react/Forest.d.ts +17 -3
  59. package/dist/react/Forest.d.ts.map +1 -1
  60. package/dist/react/ScenePipeline.d.ts +63 -0
  61. package/dist/react/ScenePipeline.d.ts.map +1 -0
  62. package/dist/react/SceneShaderHooks.d.ts +25 -0
  63. package/dist/react/SceneShaderHooks.d.ts.map +1 -0
  64. package/dist/react/Tree.d.ts +9 -2
  65. package/dist/react/Tree.d.ts.map +1 -1
  66. package/dist/react/Weather.d.ts +45 -0
  67. package/dist/react/Weather.d.ts.map +1 -0
  68. package/dist/react/Wind.d.ts +12 -1
  69. package/dist/react/Wind.d.ts.map +1 -1
  70. package/dist/react/index.d.ts +7 -1
  71. package/dist/react/index.d.ts.map +1 -1
  72. package/dist/react.js +347 -10
  73. package/dist/react.js.map +1 -1
  74. package/dist/renderer/index.d.ts +6 -0
  75. package/dist/renderer/index.d.ts.map +1 -1
  76. package/dist/scene/antialias.d.ts +35 -0
  77. package/dist/scene/antialias.d.ts.map +1 -0
  78. package/dist/scene/ao.d.ts +46 -0
  79. package/dist/scene/ao.d.ts.map +1 -0
  80. package/dist/scene/bloom.d.ts +19 -0
  81. package/dist/scene/bloom.d.ts.map +1 -0
  82. package/dist/scene/fog.d.ts +49 -0
  83. package/dist/scene/fog.d.ts.map +1 -0
  84. package/dist/scene/godrays.d.ts +37 -0
  85. package/dist/scene/godrays.d.ts.map +1 -0
  86. package/dist/scene/index.d.ts +14 -0
  87. package/dist/scene/index.d.ts.map +1 -0
  88. package/dist/scene/motion-blur.d.ts +23 -0
  89. package/dist/scene/motion-blur.d.ts.map +1 -0
  90. package/dist/scene/pipeline.d.ts +109 -0
  91. package/dist/scene/pipeline.d.ts.map +1 -0
  92. package/dist/scene/settings.d.ts +36 -0
  93. package/dist/scene/settings.d.ts.map +1 -0
  94. package/dist/scene/stack.d.ts +25 -0
  95. package/dist/scene/stack.d.ts.map +1 -0
  96. package/dist/scene/stage.d.ts +52 -0
  97. package/dist/scene/stage.d.ts.map +1 -0
  98. package/dist/scene/suggested.d.ts +12 -0
  99. package/dist/scene/suggested.d.ts.map +1 -0
  100. package/dist/scene/tone-mapping.d.ts +20 -0
  101. package/dist/scene/tone-mapping.d.ts.map +1 -0
  102. package/dist/scene/velocity.d.ts +34 -0
  103. package/dist/scene/velocity.d.ts.map +1 -0
  104. package/dist/scene.js +889 -0
  105. package/dist/scene.js.map +1 -0
  106. package/dist/season/nodes.d.ts +13 -0
  107. package/dist/season/nodes.d.ts.map +1 -1
  108. package/dist/shader-hooks-BFRtlWGI.js +275 -0
  109. package/dist/shader-hooks-BFRtlWGI.js.map +1 -0
  110. package/dist/tree/Tree.d.ts +8 -3
  111. package/dist/tree/Tree.d.ts.map +1 -1
  112. package/dist/tree/index.d.ts.map +1 -1
  113. package/dist/weather/index.d.ts +3 -0
  114. package/dist/weather/index.d.ts.map +1 -0
  115. package/dist/weather/shared.d.ts +43 -0
  116. package/dist/weather/shared.d.ts.map +1 -0
  117. package/dist/weather/snow.d.ts +87 -0
  118. package/dist/weather/snow.d.ts.map +1 -0
  119. package/dist/weather/wetness.d.ts +75 -0
  120. package/dist/weather/wetness.d.ts.map +1 -0
  121. package/dist/weather.js +288 -0
  122. package/dist/weather.js.map +1 -0
  123. package/dist/wind/Wind.d.ts +100 -5
  124. package/dist/wind/Wind.d.ts.map +1 -1
  125. package/dist/wind/burst.d.ts +28 -0
  126. package/dist/wind/burst.d.ts.map +1 -0
  127. package/dist/wind/index.d.ts +3 -2
  128. package/dist/wind/index.d.ts.map +1 -1
  129. package/dist/wind/motion.d.ts +30 -0
  130. package/dist/wind/motion.d.ts.map +1 -0
  131. package/dist/wind/node.d.ts +17 -3
  132. package/dist/wind/node.d.ts.map +1 -1
  133. package/package.json +9 -1
  134. package/dist/effects.js.map +0 -1
  135. package/dist/forest-lg61rhKM.js.map +0 -1
@@ -0,0 +1,62 @@
1
+ import type { Node } from 'three/webgpu';
2
+ import type { LiveTreeEffect } from './live';
3
+ import type { TreeEffectInput } from './mask';
4
+ import type { TreeEffectsChannels } from './pass';
5
+ import type { TreeEffectsSettings } from './suggested';
6
+ /** A built-in Tree Effect, by its key in {@link TreeEffectsSettings}. */
7
+ export type TreeEffectName = keyof TreeEffectsSettings;
8
+ /** The order the built-in Tree Effects run in (the Highlight last of them, on top). */
9
+ export declare const TREE_EFFECT_ORDER: readonly TreeEffectName[];
10
+ /** Where a custom Tree Effect runs: right before a built-in Tree Effect, or `'end'`: after all of them. */
11
+ export type TreeEffectPlace = TreeEffectName | 'end';
12
+ /**
13
+ * A Tree Effect written by the app, for `TreeEffects.addEffect()`. It is built the way the built-in
14
+ * ones are: on the colour so far and the tree mask, returning its colour node and an `update()`
15
+ * that changes its uniforms live (no new graph, no recompile).
16
+ */
17
+ export interface CustomTreeEffect<Options = undefined> {
18
+ /**
19
+ * Runs right before this built-in Tree Effect, whether that one is on or not, or with `'end'` after
20
+ * every built-in Tree Effect, the Highlight too (in the Scene Pipeline still before the Scene
21
+ * Effects); custom effects at the same place run in the order they were added. Default
22
+ * `'highlight'`: after every other built-in effect, and under the Highlight.
23
+ */
24
+ before?: TreeEffectPlace;
25
+ /**
26
+ * The optional channels the effect reads (`treeId`, `normal`): the scene pass adds them (ADR 0009)
27
+ * and they are in the effect's input. Undeclared channels are never in its input, even when a
28
+ * built-in effect has them on. Default: none (colour, tree mask, depth and camera only).
29
+ */
30
+ channels?: TreeEffectsChannels;
31
+ /**
32
+ * Builds the effect. `input.color` is the colour so far (the scene colour, or the result of the
33
+ * effects before this one); `input.mask` is the tree mask: r = any tree, g = leaves only,
34
+ * b = selected trees. Called again with the latest options whenever the graph is rebuilt.
35
+ */
36
+ build(input: TreeEffectInput, options: Options): LiveTreeEffect<Options>;
37
+ }
38
+ /** The options argument of `addEffect`: optional when the effect's options may be `undefined`. */
39
+ export type CustomTreeEffectOptions<Options> = undefined extends Options ? [options?: Options] : [options: Options];
40
+ /**
41
+ * Internal: the custom Tree Effects of a pipeline (`TreeEffects`, the Scene Pipeline) with their
42
+ * latest options. It decides their part of the graph's shape and of the scene pass's channels, and
43
+ * builds them into a graph at their places.
44
+ */
45
+ export declare class CustomTreeEffectList {
46
+ private entries;
47
+ /** The custom effects, in the order they were added. */
48
+ get effects(): readonly CustomTreeEffect<never>[];
49
+ add<Options>(effect: CustomTreeEffect<Options>, options: Options): void;
50
+ /** Stores the options (used on rebuilds) and sets them on the built effect. */
51
+ update<Options>(effect: CustomTreeEffect<Options>, options: Options): void;
52
+ /** Whether the effect was there. */
53
+ remove(effect: CustomTreeEffect<never>): boolean;
54
+ /** The channels the custom effects declare. */
55
+ channels(): TreeEffectsChannels;
56
+ /** Their part of a graph's shape: which effects, in which order and at which places. */
57
+ shape(): string;
58
+ /** Builds the custom effects placed before `name` (or at the `'end'`) onto `input.color` and returns the resulting colour. */
59
+ buildBefore(name: TreeEffectPlace, input: TreeEffectInput): Node<'vec4'>;
60
+ private find;
61
+ }
62
+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,EAAE,MAAM,EAAE,gBAAgB,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;IAKvE,+EAA+E;IAC/E,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,gBAAgB,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;IAO1E,oCAAoC;IACpC,MAAM,CAAC,MAAM,EAAE,gBAAgB,CAAC,KAAK,CAAC,GAAG,OAAO;IAMhD,+CAA+C;IAC/C,QAAQ,IAAI,mBAAmB;IAO/B,wFAAwF;IACxF,KAAK,IAAI,MAAM;IAIf,8HAA8H;IAC9H,WAAW,CAAC,IAAI,EAAE,eAAe,EAAE,KAAK,EAAE,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC;IAUxE,OAAO,CAAC,IAAI;CAGb"}
@@ -1,7 +1,9 @@
1
1
  import { RenderPipeline, type Camera, type Node, type Object3D, type Renderer, type Scene } from 'three/webgpu';
2
2
  import type { StyleName } from '../styles/registry';
3
+ import type { LiveTreeEffect } from './live';
4
+ import { CustomTreeEffectList, type CustomTreeEffect, type CustomTreeEffectOptions } from './custom';
3
5
  import type { TreeEffectInput } from './mask';
4
- import { type TreeEffectsPass } from './pass';
6
+ import { type TreeEffectsChannels, type TreeEffectsPass } from './pass';
5
7
  import { type TreeEffectsSettings } from './suggested';
6
8
  import type { ForestTree } from '../forest';
7
9
  import type { Tree } from '../tree';
@@ -12,8 +14,22 @@ import type { Tree } from '../tree';
12
14
  * Empty settings return `input.color`. `highlighted`: the trees the Highlight marks (mutable, read every frame).
13
15
  */
14
16
  export declare function applyTreeEffects(input: TreeEffectInput, settings: TreeEffectsSettings, highlighted?: readonly (Tree | ForestTree)[]): Node<'vec4'>;
17
+ /**
18
+ * The shape of a combination: what its graph is built from (the effects that are on, the glow
19
+ * radius, the outline's `betweenTrees` and the normal encoding of Inner Lines). Settings of the same
20
+ * shape only differ in uniforms.
21
+ */
22
+ export declare function treeEffectsShape(settings: TreeEffectsSettings, input: TreeEffectInput, custom?: CustomTreeEffectList): string;
23
+ /**
24
+ * {@link applyTreeEffects} with every colour and number as a uniform; `update()` needs the same shape.
25
+ * Internal (not in the /effects index): shared with the Scene Pipeline (`src/scene`). `custom`: the
26
+ * app's own Tree Effects, built in at their places (their `update()` is the list's, not this one's).
27
+ */
28
+ export declare function liveTreeEffects(input: TreeEffectInput, settings: TreeEffectsSettings, highlighted: readonly (Tree | ForestTree)[], custom?: CustomTreeEffectList): LiveTreeEffect<TreeEffectsSettings>;
15
29
  /** The suggested combination of a built-in Style, or the settings themselves; `null` = no effects. */
16
30
  export type TreeEffectsChoice = StyleName | TreeEffectsSettings | null;
31
+ /** The settings of a choice; throws for an unknown Style. Internal, shared with the Scene Pipeline. */
32
+ export declare function resolveTreeEffects(choice: TreeEffectsChoice): TreeEffectsSettings;
17
33
  export interface TreeEffectsOptions {
18
34
  /** Which effects: a Style name (its suggested combination), custom settings, or `null` (none). Default: none. */
19
35
  effects?: TreeEffectsChoice;
@@ -36,6 +52,14 @@ export interface TreeEffectsOptions {
36
52
  */
37
53
  highlighted?: (Tree | ForestTree)[];
38
54
  }
55
+ /**
56
+ * The extra channels the scene pass needs for `settings` (with the `treeId` option and the channels
57
+ * the custom effects declare). Only this set decides the scene pass's MRT: settings that need the
58
+ * same channels keep it.
59
+ */
60
+ export declare function channelsFor(settings: TreeEffectsSettings, options: Pick<TreeEffectsOptions, 'treeId'>, custom?: CustomTreeEffectList): TreeEffectsChannels;
61
+ /** A key that is equal for equal sets of channels. */
62
+ export declare function channelsKey(channels: object): string;
39
63
  /**
40
64
  * A ready-made post-processing pipeline (`RenderPipeline`) with the Tree Effects: render with
41
65
  * `effects.render()` instead of `renderer.render(scene, camera)`. Switch the combination with
@@ -52,6 +76,7 @@ export declare class TreeEffects {
52
76
  readonly highlighted: (Tree | ForestTree)[];
53
77
  private nodes;
54
78
  private current;
79
+ private readonly custom;
55
80
  private graph;
56
81
  private input;
57
82
  constructor(renderer: Renderer, scene: Scene, camera: Camera, options?: TreeEffectsOptions);
@@ -75,6 +100,20 @@ export declare class TreeEffects {
75
100
  * otherwise a new graph is built and the old one freed.
76
101
  */
77
102
  set(effects: TreeEffectsChoice): void;
103
+ /** The app's own Tree Effects, in the order they were added (see {@link addEffect}). */
104
+ get customEffects(): readonly CustomTreeEffect<never>[];
105
+ /**
106
+ * Adds a Tree Effect of the app's own (see {@link CustomTreeEffect}) with its options, at the place
107
+ * it names among the built-in effects. It stays through {@link set} until {@link removeEffect}.
108
+ * Builds a new graph, and a new scene pass if it declares a channel that is not on yet.
109
+ */
110
+ addEffect<Options>(effect: CustomTreeEffect<Options>, ...[options]: CustomTreeEffectOptions<Options>): void;
111
+ /** Changes the options of an added custom effect live, through its `update()` (no new graph, no recompile). */
112
+ updateEffect<Options>(effect: CustomTreeEffect<Options>, options: Options): void;
113
+ /** Removes a custom effect (nothing happens if it is not added); its channels go when nothing else needs them. */
114
+ removeEffect<Options>(effect: CustomTreeEffect<Options>): void;
115
+ /** Brings the scene pass and the graph in line with the settings and the custom effects. */
116
+ private rebuild;
78
117
  /**
79
118
  * GPU picking: the Tree or Forest tree under a point of the canvas (CSS pixels from its top left
80
119
  * corner, as `event.offsetX/offsetY`) in the last render, or `undefined` where no tree is drawn.
@@ -86,6 +125,8 @@ export declare class TreeEffects {
86
125
  dispose(): void;
87
126
  private disposeNodes;
88
127
  }
128
+ /** The render-target owning nodes (blur) in an effects graph, to dispose them on change. */
129
+ export declare function collectEffectNodes(output: Node, stop: Node): Node[];
89
130
  /** Shorthand for `new TreeEffects(renderer, scene, camera, options)`. */
90
131
  export declare function createTreeEffects(renderer: Renderer, scene: Scene, camera: Camera, options?: TreeEffectsOptions): TreeEffects;
91
132
  //# sourceMappingURL=effects.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"effects.d.ts","sourceRoot":"","sources":["../../src/effects/effects.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,MAAM,EAAE,KAAK,IA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E,CAEtD;IAED;;;;OAIG;IACH,SAAS,CAAC,OAAO,EAAE,MAAM,EAAE,gBAAgB,CAAC,OAAO,CAAC,EAAE,GAAG,CAAC,OAAO,CAAC,EAAE,uBAAuB,CAAC,OAAO,CAAC,GAAG,IAAI;IAK3G,+GAA+G;IAC/G,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,gBAAgB,CAAC,OAAO,CAAC,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI;IAIhF,kHAAkH;IAClH,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,gBAAgB,CAAC,OAAO,CAAC,GAAG,IAAI;IAI9D,4FAA4F;IAC5F,OAAO,CAAC,OAAO;IAuBf;;;;OAIG;IACH,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,GAAG,UAAU,GAAG,SAAS,CAAC;IAMlE,6FAA6F;IAC7F,MAAM,IAAI,IAAI;IAId,OAAO,IAAI,IAAI;IAMf,OAAO,CAAC,YAAY;CAIrB;AAED,4FAA4F;AAC5F,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,EAAE,CAWnE;AAED,yEAAyE;AACzE,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,kBAAkB,GAAG,WAAW,CAE7H"}
@@ -7,5 +7,7 @@ export { treeColorGrade, type TreeColorGradeOptions } from './grade';
7
7
  export { treeHighlight, type TreeHighlightOptions } from './highlight';
8
8
  export { TREE_ID, readTreeId, treeFromId, treeIdMRT, treeIdOf, treeIdTexture } from './tree-id';
9
9
  export { SUGGESTED_TREE_EFFECTS, type TreeEffectsSettings } from './suggested';
10
+ export { type CustomTreeEffect, type CustomTreeEffectOptions, type TreeEffectName, type TreeEffectPlace } from './custom';
11
+ export { type LiveTreeEffect } from './live';
10
12
  export { applyTreeEffects, createTreeEffects, TreeEffects, type TreeEffectsChoice, type TreeEffectsOptions, } from './effects';
11
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/effects/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,KAAK,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACjH,OAAO,EAAE,eAAe,EAAE,KAAK,mBAAmB,EAAE,KAAK,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzF,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,QAAQ,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAChG,OAAO,EAAE,sBAAsB,EAAE,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC/E,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,EACX,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,GACxB,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/effects/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,KAAK,eAAe,EAAE,KAAK,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACjH,OAAO,EAAE,eAAe,EAAE,KAAK,mBAAmB,EAAE,KAAK,eAAe,EAAE,MAAM,QAAQ,CAAC;AACzF,OAAO,EAAE,WAAW,EAAE,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,EAAE,QAAQ,EAAE,KAAK,eAAe,EAAE,MAAM,QAAQ,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,KAAK,qBAAqB,EAAE,MAAM,SAAS,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,KAAK,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACvE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,SAAS,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAChG,OAAO,EAAE,sBAAsB,EAAE,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAC/E,OAAO,EAAE,KAAK,gBAAgB,EAAE,KAAK,uBAAuB,EAAE,KAAK,cAAc,EAAE,KAAK,eAAe,EAAE,MAAM,UAAU,CAAC;AAC1H,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,WAAW,EACX,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,GACxB,MAAM,WAAW,CAAC"}
@@ -3,16 +3,24 @@ import { type Camera, type Material, type MRTNode, type Node, type Object3D, typ
3
3
  export declare const TREE_MASK = "treeMask";
4
4
  /** The part of a tree a material draws. */
5
5
  export type TreePart = 'bark' | 'leaves' | 'fruit';
6
+ /** Every tree part, in their fixed order. */
7
+ export declare const TREE_PARTS: readonly TreePart[];
6
8
  /**
7
9
  * Which tree part a material draws: 'bark', 'leaves' or 'fruit' for tree.js materials (and their clones),
8
10
  * `null` for anything else. Tree Effects only change the pixels drawn by these materials.
9
11
  */
10
12
  export declare function treePartOf(material: Material | null | undefined): TreePart | null;
13
+ /**
14
+ * @internal For a material with `treePart` 'leaves' that also draws wood (an Impostor card): the
15
+ * fragment's leaf amount (0 wood .. 1 leaves), the tree mask's g there.
16
+ */
17
+ export declare function setTreeLeafMask(material: Material, leaf: Node<'float'>): void;
11
18
  /**
12
19
  * TSL node: the tree mask value of the object being drawn, `vec4(tree, leaves, selected, 1)`:
13
20
  * r = 1 on tree pixels (bark, leaves and Fruit), g = 1 on leaf pixels, b = 1 on pixels of selected trees (the outline's
14
21
  * selection), 0 elsewhere. A per-object uniform decided from the drawn material
15
- * ({@link treePartOf}), so no tree material is changed and every other object writes 0.
22
+ * ({@link treePartOf}), so no tree material is changed and every other object writes 0. An Impostor
23
+ * card (wood and leaves in one picture) writes g per fragment, from its baked leaf flag.
16
24
  *
17
25
  * `selection`: the selected tree objects (Trees, Forests, any ancestor of tree meshes), read on
18
26
  * every draw, so it may be changed in place. `null` (default) selects every tree.
@@ -1 +1 @@
1
- {"version":3,"file":"mask.d.ts","sourceRoot":"","sources":["../../src/effects/mask.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,MAAM,EAAE,KAAK,QAAQ,EAAE,KAAK,OAAO,EAAE,KAAK,IAAI,EAAE,KAAK,QAAQ,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAG7H,4FAA4F;AAC5F,eAAO,MAAM,SAAS,aAAa,CAAC;AAEpC,2CAA2C;AAC3C,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,OAAO,CAAC;AAEnD;;;GAGG;AACH,wBAAgB,UAAU,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,GAAG,SAAS,GAAG,QAAQ,GAAG,IAAI,CAGjF;AAOD;;;;;;;;GAQG;AACH,wBAAgB,cAAc,CAAC,SAAS,GAAE,SAAS,QAAQ,EAAE,GAAG,IAAW,GA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