@casmo/tree.js 0.3.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.
Files changed (36) hide show
  1. package/README.md +186 -1
  2. package/dist/effects/effects.d.ts +51 -6
  3. package/dist/effects/effects.d.ts.map +1 -1
  4. package/dist/effects/glow.d.ts +5 -0
  5. package/dist/effects/glow.d.ts.map +1 -1
  6. package/dist/effects/grade.d.ts +3 -0
  7. package/dist/effects/grade.d.ts.map +1 -1
  8. package/dist/effects/highlight.d.ts +35 -0
  9. package/dist/effects/highlight.d.ts.map +1 -0
  10. package/dist/effects/index.d.ts +5 -1
  11. package/dist/effects/index.d.ts.map +1 -1
  12. package/dist/effects/inner-lines.d.ts +39 -0
  13. package/dist/effects/inner-lines.d.ts.map +1 -0
  14. package/dist/effects/live.d.ts +12 -0
  15. package/dist/effects/live.d.ts.map +1 -0
  16. package/dist/effects/mask.d.ts +23 -11
  17. package/dist/effects/mask.d.ts.map +1 -1
  18. package/dist/effects/outline.d.ts +12 -0
  19. package/dist/effects/outline.d.ts.map +1 -1
  20. package/dist/effects/pass.d.ts +27 -0
  21. package/dist/effects/pass.d.ts.map +1 -0
  22. package/dist/effects/screen.d.ts +31 -0
  23. package/dist/effects/screen.d.ts.map +1 -0
  24. package/dist/effects/suggested.d.ts +5 -0
  25. package/dist/effects/suggested.d.ts.map +1 -1
  26. package/dist/effects/tree-id.d.ts +50 -0
  27. package/dist/effects/tree-id.d.ts.map +1 -0
  28. package/dist/effects.js +772 -57
  29. package/dist/effects.js.map +1 -1
  30. package/dist/forest/Forest.d.ts +2 -0
  31. package/dist/forest/Forest.d.ts.map +1 -1
  32. package/dist/{forest-ChEaWJrf.js → forest-lg61rhKM.js} +5 -1
  33. package/dist/{forest-ChEaWJrf.js.map → forest-lg61rhKM.js.map} +1 -1
  34. package/dist/index.js +1 -1
  35. package/dist/react.js +1 -1
  36. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"effects.js","names":["tslColor","color","tslColor","color","tslColor","n"],"sources":["../src/effects/mask.ts","../src/effects/outline.ts","../src/effects/glow.ts","../src/effects/grade.ts","../src/effects/suggested.ts","../src/effects/effects.ts"],"sourcesContent":["import {\n UnsignedByteType,\n Vector4,\n type Camera,\n type Material,\n type MRTNode,\n type Node,\n type Object3D,\n type PassNode,\n type Scene,\n type TextureNode,\n} from 'three/webgpu';\nimport { mrt, output, pass, uniform } from 'three/tsl';\n\n/** Name of the tree mask output in a pass's MRT (`scenePass.getTextureNode(TREE_MASK)`). */\nexport const TREE_MASK = 'treeMask';\n\n/** The part of a tree a material draws. */\nexport type TreePart = 'bark' | 'leaves' | 'fruit';\n\n/**\n * Which tree part a material draws: 'bark', 'leaves' or 'fruit' for tree.js materials (and their clones),\n * `null` for anything else. Tree Effects only change the pixels drawn by these materials.\n */\nexport function treePartOf(material: Material | null | undefined): TreePart | null {\n const part: unknown = material?.userData.treePart;\n return part === 'bark' || part === 'leaves' || part === 'fruit' ? part : null;\n}\n\nfunction isSelected(object: Object3D | null, selection: readonly Object3D[]): boolean {\n for (let o = object; o; o = o.parent) if (selection.includes(o)) return true;\n return false;\n}\n\n/**\n * TSL node: the tree mask value of the object being drawn, `vec4(tree, leaves, selected, 1)`:\n * r = 1 on tree pixels (bark, leaves and Fruit), g = 1 on leaf pixels, b = 1 on pixels of selected trees (the outline's\n * selection), 0 elsewhere. A per-object uniform decided from the drawn material\n * ({@link treePartOf}), so no tree material is changed and every other object writes 0.\n *\n * `selection`: the selected tree objects (Trees, Forests, any ancestor of tree meshes), read on\n * every draw, so it may be changed in place. `null` (default) selects every tree.\n */\nexport function createTreeMask(selection: readonly Object3D[] | null = null): Node<'vec4'> {\n return uniform(new Vector4(0, 0, 0, 1)).onObjectUpdate((frame, self) => {\n const part = treePartOf(frame.material);\n const selected = part !== null && (selection === null || isSelected(frame.object, selection));\n self.value.set(part ? 1 : 0, part === 'leaves' ? 1 : 0, selected ? 1 : 0, 1);\n return undefined;\n });\n}\n\n/**\n * The MRT output that renders the tree mask ({@link createTreeMask}) next to the colour. Merge it\n * into the MRT of your own scene pass: `scenePass.setMRT(mrt({ output, normal: normalView }).merge(treeMaskMRT()))`,\n * then read it with `scenePass.getTextureNode(TREE_MASK)`.\n */\nexport function treeMaskMRT(selection: readonly Object3D[] | null = null): MRTNode {\n const node = mrt({ [TREE_MASK]: createTreeMask(selection) });\n node.setClearColor(TREE_MASK, 0x000000, 0);\n return node;\n}\n\n/** What every Tree Effect reads: the scene colour and the tree mask (screen-space nodes). */\nexport interface TreeEffectInput {\n /** Scene colour (linear, before tone mapping), e.g. `scenePass.getTextureNode('output')`. */\n color: Node<'vec4'>;\n /** Tree mask texture (see {@link createTreeMask}), e.g. `scenePass.getTextureNode(TREE_MASK)`. */\n mask: TextureNode;\n}\n\n/** A scene pass that renders the colour and the tree mask, ready for the Tree Effects. */\nexport interface TreeEffectsPass extends TreeEffectInput {\n pass: PassNode;\n}\n\n/**\n * Creates `pass(scene, camera)` with MRT `{ output, treeMask }` and returns it with its colour and\n * mask texture nodes. `selection`: the trees to outline (default `null` = all trees), see\n * {@link createTreeMask}. If your pipeline already has a scene pass, merge {@link treeMaskMRT} into it instead.\n */\nexport function treeEffectsPass(scene: Scene, camera: Camera, selection: readonly Object3D[] | null = null): TreeEffectsPass {\n const scenePass = pass(scene, camera);\n scenePass.setMRT(mrt({ output }).merge(treeMaskMRT(selection)));\n scenePass.getTexture(TREE_MASK).type = UnsignedByteType;\n return { pass: scenePass, color: scenePass.getTextureNode('output'), mask: scenePass.getTextureNode(TREE_MASK) };\n}\n","import { Color, type ColorRepresentation, type Node } from 'three/webgpu';\nimport { color as tslColor, float, mix, textureSize, uv, vec2, vec4 } from 'three/tsl';\nimport type { TreeEffectInput } from './mask';\n\n/** Tree outline settings. */\nexport interface TreeOutlineOptions {\n /** Line colour (default a dark green-brown). */\n color?: ColorRepresentation;\n /** Line width in pixels (default 2). */\n thickness?: number;\n /** Opacity of the line, 0..1 (default 1). */\n strength?: number;\n}\n\n// Eight sample directions around a pixel (unit length).\nconst D = Math.SQRT1_2;\nconst DIRECTIONS: [number, number][] = [[1, 0], [-1, 0], [0, 1], [0, -1], [D, D], [D, -D], [-D, D], [-D, -D]];\n\n/**\n * Tree Effect: an outline along the silhouettes of the selected trees (the `selection` of the\n * tree mask, see `createTreeMask`; all trees by default), around the outside of the canopy and\n * the gaps in it. The line is drawn on the inside of the silhouette, so only tree pixels change.\n */\nexport function treeOutline(input: TreeEffectInput, options: TreeOutlineOptions = {}): Node<'vec4'> {\n const { color = '#1d2a14', thickness = 2, strength = 1 } = options;\n const { mask } = input;\n const step = vec2(thickness).div(vec2(textureSize(mask) as unknown as Node<'ivec2'>));\n const centre = uv();\n // Fraction of neighbours (at `thickness` px) that are not selected tree pixels.\n let outside: Node<'float'> = float(0);\n for (const [x, y] of DIRECTIONS) {\n outside = outside.add(float(1).sub(mask.sample(centre.add(step.mul(vec2(x, y)))).b));\n }\n const edge = outside.mul(3 / DIRECTIONS.length).clamp(0, 1).mul(mask.sample(centre).b).mul(strength);\n return vec4(mix(input.color.rgb, tslColor(new Color(color)), edge), input.color.a);\n}\n","import { Color, type ColorRepresentation, type Node } from 'three/webgpu';\nimport { color as tslColor, luminance, smoothstep, vec4 } from 'three/tsl';\nimport { gaussianBlur } from 'three/addons/tsl/display/GaussianBlurNode.js';\nimport type { TreeEffectInput } from './mask';\n\n/** Leaf glow settings. */\nexport interface LeafGlowOptions {\n /** Glow colour, multiplied with the blurred leaf colour (default white). */\n color?: ColorRepresentation;\n /** Glow strength (default 0.6). */\n intensity?: number;\n /** Only leaf pixels brighter than this (linear luminance) glow; 0 = all leaves (default 0.15). */\n threshold?: number;\n /** Blur radius (Gaussian sigma, in pixels at half resolution; default 6). */\n radius?: number;\n}\n\n/**\n * Tree Effect: a soft glow of the leaves. The bright (sunlit) leaf pixels are blurred and added\n * back onto the tree pixels (leaves and the wood between them), never onto the rest of the scene.\n */\nexport function leafGlow(input: TreeEffectInput, options: LeafGlowOptions = {}): Node<'vec4'> {\n const { color = '#ffffff', intensity = 0.6, threshold = 0.15, radius = 6 } = options;\n const bright = smoothstep(threshold, threshold * 2 + 0.05, luminance(input.color.rgb));\n const leaves = vec4(input.color.rgb.mul(input.mask.g).mul(bright), 1);\n const blurred = gaussianBlur(leaves, null, radius, { resolutionScale: 0.5 });\n const glow = blurred.rgb.mul(tslColor(new Color(color))).mul(intensity).mul(input.mask.r);\n return vec4(input.color.rgb.add(glow), input.color.a);\n}\n","import { Color, type ColorRepresentation, type Node } from 'three/webgpu';\nimport { color as tslColor, float, luminance, mix, select, vec3, vec4 } from 'three/tsl';\nimport type { TreeEffectInput } from './mask';\n\n/** Tree colour grading settings (all optional; the defaults change nothing). */\nexport interface TreeColorGradeOptions {\n /** Brightness multiplier (default 1). */\n exposure?: number;\n /** 0 = grey, 1 = unchanged (default), > 1 = more saturated. */\n saturation?: number;\n /** Contrast around mid grey: 1 = unchanged (default), > 1 = more contrast. */\n contrast?: number;\n /** Colour multiplied in, e.g. a warm '#fff2dd' (default white). */\n tint?: ColorRepresentation;\n}\n\nconst MID_GREY = 0.18; // linear\n\n/**\n * Tree Effect: colour grading (exposure, tint, saturation, contrast) of the tree pixels only.\n * Returns the graded colour where the tree mask is set and `input.color` unchanged elsewhere.\n */\nexport function treeColorGrade(input: TreeEffectInput, options: TreeColorGradeOptions = {}): Node<'vec4'> {\n const { exposure = 1, saturation = 1, contrast = 1, tint = '#ffffff' } = options;\n const tinted = input.color.rgb.mul(tslColor(new Color(tint))).mul(exposure);\n const saturated = mix(vec3(luminance(tinted)), tinted, saturation).max(0);\n const contrasted = saturated.div(MID_GREY).pow(vec3(float(contrast))).mul(MID_GREY);\n return select(input.mask.r.greaterThan(0.5), vec4(contrasted, input.color.a), input.color);\n}\n","import type { StyleName } from '../styles/registry';\nimport type { TreeColorGradeOptions } from './grade';\nimport type { LeafGlowOptions } from './glow';\nimport type { TreeOutlineOptions } from './outline';\n\n/** A combination of Tree Effects; leave an effect out to skip it. `{}` = no effects. */\nexport interface TreeEffectsSettings {\n grade?: TreeColorGradeOptions;\n glow?: LeafGlowOptions;\n outline?: TreeOutlineOptions;\n}\n\n/** The suggested combination of Tree Effects for each built-in Style. */\nexport const SUGGESTED_TREE_EFFECTS: Record<StyleName, TreeEffectsSettings> = {\n // Crisp facets: a dark ink line and slightly punchier colours.\n 'low-poly': {\n grade: { saturation: 1.15, contrast: 1.1 },\n outline: { color: '#18230f', thickness: 2, strength: 0.9 },\n },\n // Storybook look: soft glowing foliage, a warm tint and a soft coloured outline.\n stylized: {\n grade: { saturation: 0.95, contrast: 1.08, tint: '#fff1e0' },\n glow: { color: '#fff6c8', intensity: 0.45, threshold: 0.3, radius: 8 },\n outline: { color: '#2b3a1c', thickness: 2, strength: 0.6 },\n },\n // Natural: only a gentle grade (warmer, a touch more contrast) and a faint sunlit leaf glow.\n realistic: {\n grade: { exposure: 1.05, contrast: 1.08, saturation: 0.95, tint: '#fff5e6' },\n glow: { color: '#e8ffc0', intensity: 0.35, threshold: 0.12, radius: 4 },\n },\n};\n","import { RenderPipeline, type Camera, type Node, type Object3D, type Renderer, type Scene } from 'three/webgpu';\nimport type { StyleName } from '../styles/registry';\nimport { leafGlow } from './glow';\nimport { treeColorGrade } from './grade';\nimport { treeEffectsPass, type TreeEffectInput, type TreeEffectsPass } from './mask';\nimport { treeOutline } from './outline';\nimport { SUGGESTED_TREE_EFFECTS, type TreeEffectsSettings } from './suggested';\n\n/**\n * Applies a combination of Tree Effects to `input` and returns the resulting colour node, for use in\n * your own post-processing pipeline (`pipeline.outputNode = applyTreeEffects(...)`, or feed it into\n * more effects). Order: colour grade, leaf glow, outline. Empty settings return `input.color`.\n */\nexport function applyTreeEffects(input: TreeEffectInput, settings: TreeEffectsSettings): Node<'vec4'> {\n let color = input.color;\n if (settings.grade) color = treeColorGrade({ color, mask: input.mask }, settings.grade);\n if (settings.glow) color = leafGlow({ color, mask: input.mask }, settings.glow);\n if (settings.outline) color = treeOutline({ color, mask: input.mask }, settings.outline);\n return color;\n}\n\n/** The suggested combination of a built-in Style, or the settings themselves; `null` = no effects. */\nexport type TreeEffectsChoice = StyleName | TreeEffectsSettings | null;\n\nfunction resolveEffects(choice: TreeEffectsChoice): TreeEffectsSettings {\n if (choice === null) return {};\n if (typeof choice !== 'string') return choice;\n const settings = (SUGGESTED_TREE_EFFECTS as Record<string, TreeEffectsSettings | undefined>)[choice];\n if (!settings) throw new Error(`No suggested Tree Effects for Style \"${choice}\"`);\n return settings;\n}\n\nexport interface TreeEffectsOptions {\n /** Which effects: a Style name (its suggested combination), custom settings, or `null` (none). Default: none. */\n effects?: TreeEffectsChoice;\n /**\n * The trees to outline (Trees, Forests, groups of them; mutable, read on every draw).\n * Default: every tree in the scene.\n */\n selection?: Object3D[];\n}\n\n/**\n * A ready-made post-processing pipeline (`RenderPipeline`) with the Tree Effects: render with\n * `effects.render()` instead of `renderer.render(scene, camera)`. Switch the combination with\n * `effects.set('stylized')` (e.g. a preview). For your own pipeline, use {@link treeEffectsPass}\n * and {@link applyTreeEffects} instead.\n */\nexport class TreeEffects {\n readonly pipeline: RenderPipeline;\n /** The scene pass (colour + tree mask). */\n readonly scenePass: TreeEffectsPass;\n private nodes: Node[] = [];\n private current: TreeEffectsSettings = {};\n\n constructor(renderer: Renderer, scene: Scene, camera: Camera, options: TreeEffectsOptions = {}) {\n this.pipeline = new RenderPipeline(renderer);\n this.scenePass = treeEffectsPass(scene, camera, options.selection ?? null);\n this.set(options.effects ?? null);\n }\n\n /** The active combination (`{}` = none). */\n get settings(): TreeEffectsSettings {\n return this.current;\n }\n\n /** Switches to a Style's suggested combination, custom settings, or none (`null`). */\n set(effects: TreeEffectsChoice): void {\n this.current = resolveEffects(effects);\n this.disposeNodes();\n const output = applyTreeEffects(this.scenePass, this.current);\n this.nodes = collectEffectNodes(output, this.scenePass.color);\n this.pipeline.outputNode = output;\n this.pipeline.needsUpdate = true;\n }\n\n /** Renders the scene with the effects (call instead of `renderer.render(scene, camera)`). */\n render(): void {\n this.pipeline.render();\n }\n\n dispose(): void {\n this.disposeNodes();\n this.scenePass.pass.dispose();\n this.pipeline.dispose();\n }\n\n private disposeNodes(): void {\n for (const node of this.nodes) node.dispose();\n this.nodes = [];\n }\n}\n\n/** The render-target owning nodes (blur) in an effects graph, to dispose them on change. */\nfunction collectEffectNodes(output: Node, stop: Node): Node[] {\n const found = new Set<Node>();\n const visit = (node: Node, seen: Set<Node>): void => {\n if (seen.has(node) || node === stop) return;\n seen.add(node);\n const n = node as Node & { isGaussianBlurNode?: boolean };\n if (n.isGaussianBlurNode) found.add(node);\n for (const child of node.getChildren()) visit(child as Node, seen);\n };\n visit(output, new Set());\n return [...found];\n}\n\n/** Shorthand for `new TreeEffects(renderer, scene, camera, options)`. */\nexport function createTreeEffects(renderer: Renderer, scene: Scene, camera: Camera, options?: TreeEffectsOptions): TreeEffects {\n return new TreeEffects(renderer, scene, camera, options);\n}\n"],"mappings":";;;;;AAeA,IAAa,YAAY;;;;;AASzB,SAAgB,WAAW,UAAwD;CACjF,MAAM,OAAgB,UAAU,SAAS;CACzC,OAAO,SAAS,UAAU,SAAS,YAAY,SAAS,UAAU,OAAO;AAC3E;AAEA,SAAS,WAAW,QAAyB,WAAyC;CACpF,KAAK,IAAI,IAAI,QAAQ,GAAG,IAAI,EAAE,QAAQ,IAAI,UAAU,SAAS,CAAC,GAAG,OAAO;CACxE,OAAO;AACT;;;;;;;;;;AAWA,SAAgB,eAAe,YAAwC,MAAoB;CACzF,OAAO,QAAQ,IAAI,QAAQ,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,gBAAgB,OAAO,SAAS;EACtE,MAAM,OAAO,WAAW,MAAM,QAAQ;EACtC,MAAM,WAAW,SAAS,SAAS,cAAc,QAAQ,WAAW,MAAM,QAAQ,SAAS;EAC3F,KAAK,MAAM,IAAI,OAAO,IAAI,GAAG,SAAS,WAAW,IAAI,GAAG,WAAW,IAAI,GAAG,CAAC;CAE7E,C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"effects.js","names":["n"],"sources":["../src/effects/mask.ts","../src/effects/tree-id.ts","../src/effects/screen.ts","../src/effects/inner-lines.ts","../src/effects/pass.ts","../src/effects/outline.ts","../src/effects/glow.ts","../src/effects/grade.ts","../src/effects/highlight.ts","../src/effects/suggested.ts","../src/effects/effects.ts"],"sourcesContent":["import { Vector4, type Camera, type Material, type MRTNode, type Node, type Object3D, type TextureNode } from 'three/webgpu';\nimport { mrt, uniform } from 'three/tsl';\n\n/** Name of the tree mask output in a pass's MRT (`scenePass.getTextureNode(TREE_MASK)`). */\nexport const TREE_MASK = 'treeMask';\n\n/** The part of a tree a material draws. */\nexport type TreePart = 'bark' | 'leaves' | 'fruit';\n\n/**\n * Which tree part a material draws: 'bark', 'leaves' or 'fruit' for tree.js materials (and their clones),\n * `null` for anything else. Tree Effects only change the pixels drawn by these materials.\n */\nexport function treePartOf(material: Material | null | undefined): TreePart | null {\n const part: unknown = material?.userData.treePart;\n return part === 'bark' || part === 'leaves' || part === 'fruit' ? part : null;\n}\n\nfunction isSelected(object: Object3D | null, selection: readonly Object3D[]): boolean {\n for (let o = object; o; o = o.parent) if (selection.includes(o)) return true;\n return false;\n}\n\n/**\n * TSL node: the tree mask value of the object being drawn, `vec4(tree, leaves, selected, 1)`:\n * r = 1 on tree pixels (bark, leaves and Fruit), g = 1 on leaf pixels, b = 1 on pixels of selected trees (the outline's\n * selection), 0 elsewhere. A per-object uniform decided from the drawn material\n * ({@link treePartOf}), so no tree material is changed and every other object writes 0.\n *\n * `selection`: the selected tree objects (Trees, Forests, any ancestor of tree meshes), read on\n * every draw, so it may be changed in place. `null` (default) selects every tree.\n */\nexport function createTreeMask(selection: readonly Object3D[] | null = null): Node<'vec4'> {\n return uniform(new Vector4(0, 0, 0, 1)).onObjectUpdate((frame, self) => {\n const part = treePartOf(frame.material);\n const selected = part !== null && (selection === null || isSelected(frame.object, selection));\n self.value.set(part ? 1 : 0, part === 'leaves' ? 1 : 0, selected ? 1 : 0, 1);\n return undefined;\n });\n}\n\n/**\n * The MRT output that renders the tree mask ({@link createTreeMask}) next to the colour. Merge it\n * into the MRT of your own scene pass: `scenePass.setMRT(mrt({ output, normal: normalView }).merge(treeMaskMRT()))`,\n * then read it with `scenePass.getTextureNode(TREE_MASK)`.\n */\nexport function treeMaskMRT(selection: readonly Object3D[] | null = null): MRTNode {\n const node = mrt({ [TREE_MASK]: createTreeMask(selection) });\n node.setClearColor(TREE_MASK, 0x000000, 0);\n return node;\n}\n\n/** What every Tree Effect reads: the scene colour and the tree mask (screen-space nodes). */\nexport interface TreeEffectInput {\n /** Scene colour (linear, before tone mapping), e.g. `scenePass.getTextureNode('output')`. */\n color: Node<'vec4'>;\n /** Tree mask texture (see {@link createTreeMask}), e.g. `scenePass.getTextureNode(TREE_MASK)`. */\n mask: TextureNode;\n /**\n * Tree ID texture (`r32uint`, see `treeIdMRT`), e.g. `scenePass.getTextureNode(TREE_ID)`; only\n * needed by effects that tell trees apart. Read it with exact texel loads, never filtered.\n */\n treeId?: TextureNode;\n /**\n * Scene depth texture, e.g. `scenePass.getTextureNode('depth')`; only needed by effects that\n * compare distances (the outline's `betweenTrees`, and Inner Lines with `camera`).\n */\n depth?: TextureNode;\n /** The camera the scene pass renders with (its near and far turn `depth` into view Z). */\n camera?: Camera;\n /**\n * View-space normal texture, e.g. `scenePass.getTextureNode('normal')` (see `treeNormalMRT`, or\n * your own normal MRT); only needed by Inner Lines. Encoded as `normalEncoding` says.\n */\n normal?: TextureNode;\n /**\n * How `normal` stores the view normal: `'color'` (default) = `directionToColor(normalView)`, as in\n * an RGBA8 target; `'direction'` = the normal itself, as in a float target.\n */\n normalEncoding?: 'color' | 'direction';\n}\n","import { NearestFilter, NoColorSpace, RedIntegerFormat, UnsignedIntType, Vector2, type BufferAttribute, type MRTNode, type Node, type Object3D, type PassNode, type Renderer, type Texture } from 'three/webgpu';\nimport { instanceIndex, mrt, select, uniform } from 'three/tsl';\nimport type { Forest, ForestTree, ForestVariant } from '../forest';\nimport type { Tree } from '../tree';\nimport { treePartOf } from './mask';\n\n/** Name of the Tree ID output in a pass's MRT (`scenePass.getTextureNode(TREE_ID)`), see {@link treeIdMRT}. */\nexport const TREE_ID = 'treeId';\n\n// The module-wide Tree ID registry (ADR 0009). Holds no strong references to trees. IDs are handed\n// out on first use: by treeIdOf() or by the first draw with the Tree ID channel.\nconst MAX_ID = 0xffffffff;\nlet nextId = 1;\nconst treeIds = new WeakMap<Tree, number>();\nconst treesById = new Map<number, WeakRef<Tree>>();\nconst forgetTree = new FinalizationRegistry<number>((id) => treesById.delete(id));\n\n/**\n * The IDs of one allocation of a Forest Variant's instanced meshes: `base + slot` for each slot\n * up to its capacity. A Variant that grows gets new meshes, and with them a new block.\n */\ninterface Block {\n base: number;\n capacity: number;\n variant: WeakRef<ForestVariant>;\n /** The instance matrix buffer the Variant's meshes shared when the block was reserved. */\n matrices: WeakRef<BufferAttribute>;\n}\nconst blockOf = new WeakMap<BufferAttribute, Block>();\n/** Every live block, by ascending `base`. */\nconst blocks: Block[] = [];\nconst forgetBlock = new FinalizationRegistry<Block>((block) => blocks.splice(blocks.indexOf(block), 1));\n\nfunction reserve(count: number): number {\n if (nextId + count - 1 > MAX_ID) throw new RangeError('Tree IDs exhausted: more than 4294967295 handed out in this session');\n const base = nextId;\n nextId += count;\n return base;\n}\n\nfunction idOfTree(tree: Tree): number {\n let id = treeIds.get(tree);\n if (id === undefined) {\n id = reserve(1);\n treeIds.set(tree, id);\n treesById.set(id, new WeakRef(tree));\n forgetTree.register(tree, id);\n }\n return id;\n}\n\n/** Whether the Variant still draws with the meshes the block was reserved for. */\nfunction isCurrent(block: Block, variant: ForestVariant): boolean {\n return variant.wood.instanceMatrix === block.matrices.deref() && variant.wood.parent !== null;\n}\n\nfunction blockOfVariant(variant: ForestVariant): Block {\n const matrices = variant.wood.instanceMatrix;\n let block = blockOf.get(matrices);\n if (!block) {\n block = { base: reserve(variant.capacity), capacity: variant.capacity, variant: new WeakRef(variant), matrices: new WeakRef(matrices) };\n blockOf.set(matrices, block);\n blocks.push(block);\n forgetBlock.register(matrices, block);\n }\n return block;\n}\n\nfunction blockAt(id: number): Block | undefined {\n let lo = 0;\n let hi = blocks.length - 1;\n while (lo <= hi) {\n const mid = (lo + hi) >> 1;\n const block = blocks[mid]!;\n if (id < block.base) hi = mid - 1;\n else if (id >= block.base + block.capacity) lo = mid + 1;\n else return block;\n }\n return undefined;\n}\n\n/**\n * The current Tree ID of a Tree or a Forest tree, or `undefined` for a Forest tree that was removed.\n * IDs are handed out lazily, on first use: by this function or by the first draw with the Tree ID\n * channel, whichever comes first. So asking for a Tree's ID before it is drawn reserves it then\n * (and for a Forest tree the block of its Variant's current meshes). A Forest tree's ID is\n * frame-relative (see {@link treeFromId}).\n */\nexport function treeIdOf(tree: Tree | ForestTree): number | undefined {\n if ('isTree' in tree) return idOfTree(tree);\n const variant = tree.owner;\n if (!variant || tree.slot < 0 || variant.wood.parent === null) return undefined;\n return blockOfVariant(variant).base + tree.slot;\n}\n\n/**\n * The Tree or Forest tree with this Tree ID, resolved against the current trees, or `undefined`\n * for 0 (not a tree), an unknown ID or a tree that is gone.\n */\nexport function treeFromId(id: number): Tree | ForestTree | undefined {\n if (!Number.isInteger(id) || id <= 0) return undefined;\n const tree = treesById.get(id)?.deref();\n if (tree) return tree;\n const block = blockAt(id);\n const variant = block?.variant.deref();\n if (!block || !variant || !isCurrent(block, variant)) return undefined;\n return variant.trees[id - block.base];\n}\n\n/**\n * The ID the drawn object writes: a Tree's ID for each of its parts, the block base of a Forest\n * Variant's mesh (the shader adds the instance index), 0 for anything else.\n */\nfunction drawnId(object: Object3D | null): number {\n for (let o = object; o; o = o.parent) {\n if ((o as Partial<Tree>).isTree) return idOfTree(o as Tree);\n const forest = o.parent as Partial<Forest> | null;\n if (forest?.isForest) {\n const variant = forest.variants!.find((v) => v.meshes.includes(o as never));\n if (variant) return blockOfVariant(variant).base;\n }\n }\n return 0;\n}\n\n/** The parts of three's WebGL2 fallback backend (`renderer.backend`) the Tree ID relies on; not public API. */\ninterface WebGLBackendInternals {\n isWebGLBackend?: boolean;\n gl?: WebGL2RenderingContext;\n has(object: object): boolean;\n get(object: object): { textureGPU?: WebGLTexture; glInternalFormat?: number };\n}\n\n/** The WebGL2 context when `renderer` runs on three's WebGL2 fallback, `undefined` on WebGPU. */\nfunction webglOf(renderer: Renderer): { backend: WebGLBackendInternals; gl: WebGL2RenderingContext } | undefined {\n const backend = renderer.backend as unknown as WebGLBackendInternals;\n return backend.isWebGLBackend === true && backend.gl ? { backend, gl: backend.gl } : undefined;\n}\n\n/** Per Tree ID texture: a framebuffer with just that texture attached, to clear it on its own. */\nconst clearTargets = new WeakMap<Texture, { framebuffer: WebGLFramebuffer; attached: WebGLTexture | null }>();\n\n/**\n * WebGL2 only (a no-op on WebGPU, which clears integer targets correctly): clears the Tree ID\n * texture to 0. three's WebGL2 fallback clears every colour attachment of a render target with\n * `clearBufferfv`, which is invalid for an integer target: the GL ignores it (logging one\n * `GL_INVALID_OPERATION` warning per frame in the console, from three's own clear, that we cannot\n * avoid without three changing its clear) and the IDs of the last frame would stay wherever nothing\n * is drawn now. So this clears the texture with `clearBufferuiv` through a framebuffer of its own,\n * restoring the GL bindings and state it touches, before the scene pass renders (see\n * {@link treeIdTexture}).\n *\n * Depends on three internals: `renderer.backend.gl` (the WebGL2 context) and\n * `renderer.backend.get(texture)` (`textureGPU`, `glInternalFormat`). A texture three has not\n * allocated yet is skipped: new GL storage starts at 0.\n */\nfunction clearTreeIdTextureOnWebGL(renderer: Renderer, texture: Texture): void {\n const webgl = webglOf(renderer);\n if (!webgl || !webgl.backend.has(texture)) return;\n const { gl } = webgl;\n const { textureGPU, glInternalFormat } = webgl.backend.get(texture);\n if (!textureGPU || glInternalFormat !== gl.R32UI) return;\n\n let target = clearTargets.get(texture);\n if (!target) {\n const framebuffer = gl.createFramebuffer();\n target = { framebuffer, attached: null };\n clearTargets.set(texture, target);\n texture.addEventListener('dispose', () => {\n gl.deleteFramebuffer(framebuffer);\n clearTargets.delete(texture);\n });\n }\n const previous = gl.getParameter(gl.DRAW_FRAMEBUFFER_BINDING) as WebGLFramebuffer | null;\n const scissor = gl.isEnabled(gl.SCISSOR_TEST);\n const mask = gl.getParameter(gl.COLOR_WRITEMASK) as [boolean, boolean, boolean, boolean];\n gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, target.framebuffer);\n // three makes a new GL texture when the target is resized: attach the current one.\n if (target.attached !== textureGPU) {\n gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, textureGPU, 0);\n target.attached = textureGPU;\n }\n if (scissor) gl.disable(gl.SCISSOR_TEST);\n gl.colorMask(true, true, true, true);\n gl.clearBufferuiv(gl.COLOR, 0, [0, 0, 0, 0]);\n gl.colorMask(...mask);\n if (scissor) gl.enable(gl.SCISSOR_TEST);\n gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, previous);\n}\n\nconst clearing = new WeakSet<PassNode>();\n\n/**\n * Makes the scene pass clear its Tree ID texture (on WebGL2, see {@link clearTreeIdTextureOnWebGL})\n * right before it renders, every frame, also when nothing is drawn.\n */\nfunction clearTreeIdsBeforeEachRender(scenePass: PassNode, texture: Texture): void {\n if (clearing.has(scenePass)) return;\n clearing.add(scenePass);\n const render = scenePass.updateBefore.bind(scenePass);\n scenePass.updateBefore = (frame) => {\n if (frame.renderer) clearTreeIdTextureOnWebGL(frame.renderer, texture);\n return render(frame);\n };\n}\n\n/**\n * TSL node: the Tree ID of the tree being drawn (`uint`), 0 for anything that is not a tree. A Tree\n * writes one ID for all its parts (wood, leaves, Fruit); a Forest tree writes its Variant's block\n * base + its instance index. A per-object uniform decided from the drawn object, so no material is\n * changed. It ignores the outline's `selection`: every tree gets its ID.\n */\nfunction createTreeId(): Node<'uint'> {\n const base = uniform(0, 'uint').onObjectUpdate((frame, node) => {\n node.value = treePartOf(frame.material) === null ? 0 : drawnId(frame.object);\n return undefined;\n });\n return select(base.equal(0), base, base.add(instanceIndex)) as Node<'uint'>;\n}\n\n/**\n * The MRT output that renders each tree's Tree ID ({@link createTreeId}) next to the colour, opt-in\n * next to {@link treeMaskMRT}. Merge it into the MRT of your own scene pass and always call\n * {@link treeIdTexture} on that pass afterwards:\n * `scenePass.setMRT(mrt({ output }).merge(treeMaskMRT()).merge(treeIdMRT())); treeIdTexture(scenePass);`.\n * Note that this turns MSAA off on that scene pass (an integer target cannot be multisampled, see\n * {@link treeIdTexture}). Read IDs back with {@link readTreeId}, or in a shader with exact texel\n * loads (never filtered).\n */\nexport function treeIdMRT(): MRTNode {\n const node = mrt({ [TREE_ID]: createTreeId() });\n node.setClearColor(TREE_ID, 0x000000, 0);\n return node;\n}\n\n/**\n * Makes the Tree ID target of a scene pass ({@link treeIdMRT} merged into its MRT) one 32-bit\n * unsigned integer per pixel (`r32uint`, read without filtering) and returns its texture. Call it\n * once after `setMRT`, before the first render.\n *\n * **MSAA is turned off on this scene pass**: an integer target cannot be multisampled, and all the\n * targets of a pass share one sample count, so this sets `scenePass.options.samples = 0`, also with\n * an `antialias: true` renderer (the colour then has aliased edges unless you add FXAA/SMAA after\n * the pass). That is a hard constraint of WebGPU and WebGL2, not a choice of tree.js.\n *\n * On the WebGL2 fallback it also makes the pass clear the Tree ID target to 0 right before every\n * render (three cannot clear integer targets there), so a pixel where nothing is drawn reads 0.\n */\nexport function treeIdTexture(scenePass: PassNode): Texture {\n scenePass.options.samples = 0;\n const texture = scenePass.getTexture(TREE_ID);\n texture.format = RedIntegerFormat;\n texture.type = UnsignedIntType;\n texture.minFilter = texture.magFilter = NearestFilter;\n texture.generateMipmaps = false;\n texture.colorSpace = NoColorSpace;\n clearTreeIdsBeforeEachRender(scenePass, texture);\n return texture;\n}\n\n/**\n * Reads the Tree ID under a point of the canvas from the last render of `scenePass` (with\n * {@link treeIdMRT} in its MRT): `x`, `y` in CSS pixels from the canvas's top left corner, as in\n * `event.offsetX/offsetY`. Resolves to 0 off the canvas or where no tree is drawn. Resolve the ID\n * with {@link treeFromId} right away: IDs are frame-relative.\n */\nexport async function readTreeId(renderer: Renderer, scenePass: PassNode, x: number, y: number): Promise<number> {\n const texture = scenePass.getTexture(TREE_ID);\n const target = scenePass.renderTarget;\n const index = target.textures.indexOf(texture);\n if (index < 0) throw new Error('readTreeId: the scene pass has no Tree ID target; merge treeIdMRT() into its MRT');\n const css = renderer.getSize(new Vector2());\n const px = Math.floor((x * target.width) / css.x);\n const py = Math.floor((y * target.height) / css.y);\n if (!(px >= 0 && py >= 0 && px < target.width && py < target.height)) return 0;\n // WebGL reads with the origin at the bottom left, WebGPU at the top left.\n const flipY = webglOf(renderer) !== undefined;\n const data = await renderer.readRenderTargetPixelsAsync(target, px, flipY ? target.height - 1 - py : py, 1, 1, index);\n return Number(data[0] ?? 0);\n}\n","// Screen-space helpers shared by the Tree Effects (internal, not exported from the package).\nimport type { Camera, Node, NodeBuilder, TextureNode } from 'three/webgpu';\nimport { Fn, ivec2, logarithmicDepthToViewZ, orthographicDepthToViewZ, perspectiveDepthToViewZ, screenCoordinate, textureSize, uint, uniform, vec2 } from 'three/tsl';\n\nconst DIAGONAL = Math.SQRT1_2;\n/** Eight sample directions around a pixel, unit length: the four axes and the four diagonals. */\nexport const EIGHT_DIRECTIONS: readonly (readonly [number, number])[] = [\n [1, 0], [-1, 0], [0, 1], [0, -1],\n [DIAGONAL, DIAGONAL], [DIAGONAL, -DIAGONAL], [-DIAGONAL, DIAGONAL], [-DIAGONAL, -DIAGONAL],\n];\n/** Four sample directions around a pixel: the axes. */\nexport const FOUR_DIRECTIONS: readonly (readonly [number, number])[] = [[1, 0], [-1, 0], [0, 1], [0, -1]];\n\n/** The size of a texture in pixels, as a `vec2`. */\nexport function sizeOf(texture: TextureNode): Node<'vec2'> {\n return vec2(textureSize(texture) as unknown as Node<'ivec2'>);\n}\n\n/**\n * The texel `offset` px from the pixel being shaded, clamped to the texture, for exact texel loads\n * (`texture.load(texelAt(texture, offset))`) of unfiltered targets such as the Tree ID.\n */\nexport function texelAt(texture: TextureNode, offset: Node<'vec2'>): Node<'ivec2'> {\n return ivec2(screenCoordinate.xy.add(offset).floor().clamp(vec2(0), sizeOf(texture).sub(1)));\n}\n\n/** The Tree ID at a texel (see {@link texelAt}): 0 where no tree is drawn. */\nexport function treeIdAt(treeId: TextureNode, texel: Node<'ivec2'>): Node<'uint'> {\n return uint(treeId.load(texel).x);\n}\n\n/** An optional input an effect needs, or an error naming the effect, the input and where to get it. */\nexport function requireInput<T>(effect: string, value: T | undefined, name: string, hint: string): T {\n if (value === undefined) throw new Error(`${effect} needs the \\`${name}\\` input: ${hint}`);\n return value;\n}\n\n/**\n * Whether the scene depth `depth` is further from the camera than `than` (both raw values of the\n * scene pass's depth texture). Decided per renderer when the shader is built: a reversed depth\n * buffer (`reversedDepthBuffer`) stores 1 at the near plane and 0 at the far plane, a standard or\n * logarithmic one the other way around.\n */\nexport const isFurther = Fn(([depth, than]: [Node<'float'>, Node<'float'>], builder: NodeBuilder) =>\n builder.renderer.reversedDepthBuffer === true ? depth.lessThan(than) : depth.greaterThan(than),\n) as unknown as (depth: Node<'float'>, than: Node<'float'>) => Node<'bool'>;\n\n/**\n * A function turning a raw value of the scene pass's depth texture into view Z (negative, in world\n * units) for `camera` (its near and far are read every render). It follows the renderer's depth\n * buffer: standard, reversed (`reversedDepthBuffer`) or logarithmic (`logarithmicDepthBuffer`,\n * which three only applies to perspective cameras).\n */\nexport function viewZFromDepth(camera: Camera): (depth: Node<'float'>) => Node<'float'> {\n const lens = camera as Camera & { near: number; far: number; isOrthographicCamera?: boolean };\n const near = uniform(0).onRenderUpdate((_, node) => {\n node.value = lens.near;\n return undefined;\n });\n const far = uniform(0).onRenderUpdate((_, node) => {\n node.value = lens.far;\n return undefined;\n });\n const orthographic = lens.isOrthographicCamera === true;\n // orthographicDepthToViewZ and perspectiveDepthToViewZ handle the reversed depth buffer themselves.\n const convert = Fn(([depth]: [Node<'float'>], builder: NodeBuilder) => {\n if (orthographic) return orthographicDepthToViewZ(depth, near, far);\n if (builder.renderer.logarithmicDepthBuffer === true) return logarithmicDepthToViewZ(depth, near, far);\n return perspectiveDepthToViewZ(depth, near, far);\n });\n return (depth) => convert(depth) as unknown as Node<'float'>;\n}\n","import { Color, type ColorRepresentation, type MRTNode, type Node } from 'three/webgpu';\nimport { abs, dot, float, max, mix, mrt, normalView, packNormalToRGB, smoothstep, uniform, unpackRGBToNormal, uv, vec2, vec4 } from 'three/tsl';\nimport type { LiveTreeEffect } from './live';\nimport type { TreeEffectInput } from './mask';\nimport { FOUR_DIRECTIONS, requireInput, sizeOf, viewZFromDepth } from './screen';\n\n/** Name of the view normal output in a pass's MRT (`scenePass.getTextureNode('normal')`), see {@link treeNormalMRT}. */\nexport const TREE_NORMAL = 'normal';\n\n/**\n * The MRT output that renders view normals in the `'color'` encoding (`packNormalToRGB(normalView)`,\n * the same as `directionToColor`) to a target named `normal`, for Inner Lines. Merge it into the MRT\n * of your own scene pass and make the target RGBA8:\n * `scenePass.setMRT(mrt({ output }).merge(treeMaskMRT()).merge(treeNormalMRT())); scenePass.getTexture('normal').type = UnsignedByteType;`.\n * If your pipeline already renders normals (GTAO, SSR), pass that texture as the `normal` input instead.\n */\nexport function treeNormalMRT(): MRTNode {\n return mrt({ [TREE_NORMAL]: packNormalToRGB(normalView) });\n}\n\n/** Inner Lines settings. */\nexport interface InnerLinesOptions {\n /** Line colour (default a dark green-brown). */\n color?: ColorRepresentation;\n /** How far apart (in pixels) the compared pixels are, which sets the line width (default 1). */\n thickness?: number;\n /** Opacity of the lines, 0..1 (default 1). */\n strength?: number;\n /** A line where the normals of neighbouring pixels differ by more than this, as 1 − dot (default 0.4). */\n normalThreshold?: number;\n /** A line where neighbouring pixels step away by more than this, as relative depth |Δz| / z (default 0.02). */\n depthThreshold?: number;\n}\n\n/**\n * Tree Effect: ink lines inside the trees where the surface folds (normal edges) or steps away\n * from the viewer (depth edges), such as around each leaf clump. Only drawn on tree pixels (of\n * every tree, regardless of the outline's `selection`), and only from neighbours that are tree\n * pixels too: the silhouette is left to the outline. Needs the `depth`, `camera` and `normal` inputs\n * (`treeEffectsPass(scene, camera, null, { normal: true })` has them) and throws without them.\n * Works with a standard, reversed (`reversedDepthBuffer`) or logarithmic (`logarithmicDepthBuffer`)\n * depth buffer, and with perspective and orthographic cameras.\n */\nexport function innerLines(input: TreeEffectInput, options: InnerLinesOptions = {}): Node<'vec4'> {\n return liveInnerLines(input, options).node;\n}\n\n/** {@link innerLines} with its settings as uniforms; the normal encoding is fixed when built. */\nexport function liveInnerLines(input: TreeEffectInput, options: InnerLinesOptions = {}): LiveTreeEffect<InnerLinesOptions> {\n const normal = requireInput('innerLines', input.normal, 'normal', \"view normals, e.g. treeNormalMRT() or your own normal MRT (with `normalEncoding`)\");\n const depth = requireInput('innerLines', input.depth, 'depth', \"the scene pass's depth, scenePass.getTextureNode('depth')\");\n const camera = requireInput('innerLines', input.camera, 'camera', 'the camera the scene pass renders with');\n\n const color = uniform(new Color());\n const thickness = uniform(0);\n const strength = uniform(0);\n const normalLow = uniform(0);\n const normalHigh = uniform(0);\n const depthLow = uniform(0);\n const depthHigh = uniform(0);\n const update = (o: InnerLinesOptions): void => {\n const n = o.normalThreshold ?? 0.4;\n const d = o.depthThreshold ?? 0.02;\n color.value.set(o.color ?? '#1d2a14');\n thickness.value = o.thickness ?? 1;\n strength.value = o.strength ?? 1;\n // A soft step around each threshold, so lines fade in rather than flicker.\n normalLow.value = n * 0.75;\n normalHigh.value = n * 1.25;\n depthLow.value = d * 0.5;\n depthHigh.value = d * 1.5;\n };\n update(options);\n\n // View Z for the relative depth step; follows a standard, reversed or logarithmic depth buffer.\n const toViewZ = viewZFromDepth(camera);\n const viewZ = (at: Node<'vec2'>): Node<'float'> => toViewZ(depth.sample(at).r);\n const direction = input.normalEncoding === 'direction';\n const normalAt = (at: Node<'vec2'>): Node<'vec3'> => {\n const n = normal.sample(at).rgb;\n return (direction ? n : unpackRGBToNormal(n)).normalize() as Node<'vec3'>;\n };\n\n const { mask } = input;\n const step = vec2(thickness).div(sizeOf(mask));\n const centre = uv();\n const n0 = normalAt(centre);\n const z0 = viewZ(centre);\n let edge: Node<'float'> = float(0);\n for (const [x, y] of FOUR_DIRECTIONS) {\n const at = centre.add(step.mul(vec2(x, y)));\n const normalEdge = smoothstep(normalLow, normalHigh, float(1).sub(dot(n0, normalAt(at))));\n const depthEdge = smoothstep(depthLow, depthHigh, abs(viewZ(at).sub(z0)).div(abs(z0)));\n // Only neighbours that are tree pixels count: the silhouette is the outline's.\n edge = max(edge, max(normalEdge, depthEdge).mul(mask.sample(at).r));\n }\n const line = edge.mul(mask.sample(centre).r).mul(strength);\n return { node: vec4(mix(input.color.rgb, color, line), input.color.a), update };\n}\n","import { UnsignedByteType, type Camera, type Object3D, type PassNode, type Scene } from 'three/webgpu';\nimport { mrt, output, pass } from 'three/tsl';\nimport { TREE_MASK, treeMaskMRT, type TreeEffectInput } from './mask';\nimport { TREE_ID, treeIdMRT, treeIdTexture } from './tree-id';\nimport { TREE_NORMAL, treeNormalMRT } from './inner-lines';\n\n/**\n * The opt-in extra channels of a scene pass, next to the colour and the tree mask (which are always\n * there). Each one adds an MRT target, so leave them off unless an effect (or picking) needs them.\n */\nexport interface TreeEffectsChannels {\n /**\n * The Tree ID target (`treeIdMRT`), for effects that tell trees apart and for picking. Turns MSAA\n * off on the scene pass (see `treeIdTexture`).\n */\n treeId?: boolean;\n /** The view normal target (`treeNormalMRT`, RGBA8, the 'color' encoding), for Inner Lines. */\n normal?: boolean;\n}\n\n/** A scene pass that renders the colour, the tree mask and the chosen channels, ready for the Tree Effects. */\nexport interface TreeEffectsPass extends TreeEffectInput {\n pass: PassNode;\n}\n\n/**\n * Creates `pass(scene, camera)` with MRT `{ output, treeMask }` (plus the opt-in `channels`, e.g.\n * `{ treeId: true }`, `{ normal: true }`) and returns it with the texture nodes of every target (and the depth and camera) as the effects' inputs.\n * `selection`: the trees to outline (default `null` = all trees), see `createTreeMask`. If your\n * pipeline already has a scene pass, merge `treeMaskMRT` (and `treeIdMRT`) into it instead.\n */\nexport function treeEffectsPass(\n scene: Scene,\n camera: Camera,\n selection: readonly Object3D[] | null = null,\n channels: TreeEffectsChannels = {},\n): TreeEffectsPass {\n const scenePass = pass(scene, camera);\n let outputs = mrt({ output }).merge(treeMaskMRT(selection));\n if (channels.treeId) outputs = outputs.merge(treeIdMRT());\n if (channels.normal) outputs = outputs.merge(treeNormalMRT());\n scenePass.setMRT(outputs);\n scenePass.getTexture(TREE_MASK).type = UnsignedByteType;\n const input: TreeEffectsPass = {\n pass: scenePass,\n color: scenePass.getTextureNode('output'),\n mask: scenePass.getTextureNode(TREE_MASK),\n depth: scenePass.getTextureNode('depth'),\n camera,\n };\n if (channels.treeId) {\n treeIdTexture(scenePass);\n input.treeId = scenePass.getTextureNode(TREE_ID);\n }\n if (channels.normal) {\n scenePass.getTexture(TREE_NORMAL).type = UnsignedByteType;\n input.normal = scenePass.getTextureNode(TREE_NORMAL);\n input.normalEncoding = 'color';\n }\n return input;\n}\n","import { Color, type ColorRepresentation, type Node } from 'three/webgpu';\nimport { float, max, mix, select, uint, uniform, uv, vec2, vec4 } from 'three/tsl';\nimport type { LiveTreeEffect } from './live';\nimport type { TreeEffectInput } from './mask';\nimport { EIGHT_DIRECTIONS, isFurther, requireInput, sizeOf, texelAt, treeIdAt } from './screen';\n\n/** Tree outline settings. */\nexport interface TreeOutlineOptions {\n /** Line colour (default a dark green-brown). */\n color?: ColorRepresentation;\n /** Line width in pixels (default 2). */\n thickness?: number;\n /** Opacity of the line, 0..1 (default 1). */\n strength?: number;\n /**\n * Also draw the line between overlapping trees (Tree–Tree, Forest tree–Forest tree, Tree–Forest\n * tree): on a selected tree pixel next to another tree that is further away, so the line lies on\n * the front tree's side, as thick as the outer outline (with a standard, reversed or logarithmic\n * depth buffer). Needs the `treeId` and `depth` inputs (see `treeEffectsPass`). Default false.\n * Changing it builds a new graph.\n */\n betweenTrees?: boolean;\n}\n\n/**\n * Tree Effect: an outline along the silhouettes of the selected trees (the `selection` of the\n * tree mask, see `createTreeMask`; all trees by default), around the outside of the canopy and\n * the gaps in it. The line is drawn on the inside of the silhouette, so only tree pixels change.\n * With `betweenTrees`, it is also drawn where a tree overlaps another one behind it.\n */\nexport function treeOutline(input: TreeEffectInput, options: TreeOutlineOptions = {}): Node<'vec4'> {\n return liveTreeOutline(input, options).node;\n}\n\n/** {@link treeOutline} with its settings as uniforms. */\nexport function liveTreeOutline(input: TreeEffectInput, options: TreeOutlineOptions = {}): LiveTreeEffect<TreeOutlineOptions> {\n const color = uniform(new Color());\n const thickness = uniform(0);\n const strength = uniform(0);\n const update = (o: TreeOutlineOptions): void => {\n color.value.set(o.color ?? '#1d2a14');\n thickness.value = o.thickness ?? 2;\n strength.value = o.strength ?? 1;\n };\n update(options);\n\n const { mask } = input;\n const step = vec2(thickness).div(sizeOf(mask));\n const centre = uv();\n // Fraction of neighbours (at `thickness` px) that are not selected tree pixels.\n // With betweenTrees, a neighbour of another tree that is further away counts as outside too.\n const behind = options.betweenTrees === true ? otherTreeBehind(input, thickness) : null;\n let outside: Node<'float'> = float(0);\n for (const [x, y] of EIGHT_DIRECTIONS) {\n const notSelected = float(1).sub(mask.sample(centre.add(step.mul(vec2(x, y)))).b);\n outside = outside.add(behind ? max(notSelected, behind(x, y)) : notSelected);\n }\n const edge = outside.mul(3 / EIGHT_DIRECTIONS.length).clamp(0, 1).mul(mask.sample(centre).b).mul(strength);\n return { node: vec4(mix(input.color.rgb, color, edge), input.color.a), update };\n}\n\n/**\n * For `betweenTrees`: a function giving, per direction, 1 where the neighbour at `thickness` px is a\n * different tree (another nonzero Tree ID) that is further from the camera than this pixel, 0\n * elsewhere, so the line lies on the front tree's side. IDs and depths are read with exact texel\n * loads; \"further\" follows the renderer's depth buffer (standard, reversed or logarithmic).\n */\nfunction otherTreeBehind(input: TreeEffectInput, thickness: Node<'float'>): (x: number, y: number) => Node<'float'> {\n const how = 'use treeEffectsPass(scene, camera, selection, { treeId: true }), which has both';\n const treeId = requireInput('treeOutline with betweenTrees', input.treeId, 'treeId', how);\n const depth = requireInput('treeOutline with betweenTrees', input.depth, 'depth', how);\n const here = texelAt(treeId, vec2(0));\n const id = treeIdAt(treeId, here);\n const z = depth.load(here).x;\n return (x, y) => {\n const there = texelAt(treeId, vec2(x, y).mul(thickness));\n const other = treeIdAt(treeId, there);\n const further = isFurther(depth.load(there).x, z);\n return select(other.notEqual(uint(0)).and(other.notEqual(id)).and(further), float(1), float(0));\n };\n}\n","import { Color, type ColorRepresentation, type Node } from 'three/webgpu';\nimport { luminance, smoothstep, uniform, vec4 } from 'three/tsl';\nimport { gaussianBlur } from 'three/addons/tsl/display/GaussianBlurNode.js';\nimport type { LiveTreeEffect } from './live';\nimport type { TreeEffectInput } from './mask';\n\n/** Leaf glow settings. */\nexport interface LeafGlowOptions {\n /** Glow colour, multiplied with the blurred leaf colour (default white). */\n color?: ColorRepresentation;\n /** Glow strength (default 0.6). */\n intensity?: number;\n /** Only leaf pixels brighter than this (linear luminance) glow; 0 = all leaves (default 0.15). */\n threshold?: number;\n /** Blur radius (Gaussian sigma, in pixels at half resolution; default 6). */\n radius?: number;\n}\n\n/** The blur radius of leaf glow settings (part of a Tree Effects graph's shape). */\nexport function glowRadius(options: LeafGlowOptions): number {\n return options.radius ?? 6;\n}\n\n/**\n * Tree Effect: a soft glow of the leaves. The bright (sunlit) leaf pixels are blurred and added\n * back onto the tree pixels (leaves and the wood between them), never onto the rest of the scene.\n */\nexport function leafGlow(input: TreeEffectInput, options: LeafGlowOptions = {}): Node<'vec4'> {\n return liveLeafGlow(input, options).node;\n}\n\n/** {@link leafGlow} with its settings as uniforms; `radius` is fixed when built. */\nexport function liveLeafGlow(input: TreeEffectInput, options: LeafGlowOptions = {}): LiveTreeEffect<LeafGlowOptions> {\n const color = uniform(new Color());\n const intensity = uniform(0);\n const low = uniform(0);\n const high = uniform(0);\n const update = (o: LeafGlowOptions): void => {\n const threshold = o.threshold ?? 0.15;\n color.value.set(o.color ?? '#ffffff');\n intensity.value = o.intensity ?? 0.6;\n low.value = threshold;\n high.value = threshold * 2 + 0.05;\n };\n update(options);\n\n const bright = smoothstep(low, high, luminance(input.color.rgb));\n const leaves = vec4(input.color.rgb.mul(input.mask.g).mul(bright), 1);\n const blurred = gaussianBlur(leaves, null, glowRadius(options), { resolutionScale: 0.5 });\n const glow = blurred.rgb.mul(color).mul(intensity).mul(input.mask.r);\n return { node: vec4(input.color.rgb.add(glow), input.color.a), update };\n}\n","import { Color, type ColorRepresentation, type Node } from 'three/webgpu';\nimport { luminance, mix, select, uniform, vec3, vec4 } from 'three/tsl';\nimport type { LiveTreeEffect } from './live';\nimport type { TreeEffectInput } from './mask';\n\n/** Tree colour grading settings (all optional; the defaults change nothing). */\nexport interface TreeColorGradeOptions {\n /** Brightness multiplier (default 1). */\n exposure?: number;\n /** 0 = grey, 1 = unchanged (default), > 1 = more saturated. */\n saturation?: number;\n /** Contrast around mid grey: 1 = unchanged (default), > 1 = more contrast. */\n contrast?: number;\n /** Colour multiplied in, e.g. a warm '#fff2dd' (default white). */\n tint?: ColorRepresentation;\n}\n\nconst MID_GREY = 0.18; // linear\n\n/**\n * Tree Effect: colour grading (exposure, tint, saturation, contrast) of the tree pixels only.\n * Returns the graded colour where the tree mask is set and `input.color` unchanged elsewhere.\n */\nexport function treeColorGrade(input: TreeEffectInput, options: TreeColorGradeOptions = {}): Node<'vec4'> {\n return liveTreeColorGrade(input, options).node;\n}\n\n/** {@link treeColorGrade} with its settings as uniforms. */\nexport function liveTreeColorGrade(input: TreeEffectInput, options: TreeColorGradeOptions = {}): LiveTreeEffect<TreeColorGradeOptions> {\n const tint = uniform(new Color());\n const exposure = uniform(0);\n const saturation = uniform(0);\n const contrast = uniform(0);\n const update = (o: TreeColorGradeOptions): void => {\n tint.value.set(o.tint ?? '#ffffff');\n exposure.value = o.exposure ?? 1;\n saturation.value = o.saturation ?? 1;\n contrast.value = o.contrast ?? 1;\n };\n update(options);\n\n const tinted = input.color.rgb.mul(tint).mul(exposure);\n const saturated = mix(vec3(luminance(tinted)), tinted, saturation).max(0);\n const contrasted = saturated.div(MID_GREY).pow(vec3(contrast)).mul(MID_GREY);\n const node = select(input.mask.r.greaterThan(0.5), vec4(contrasted, input.color.a), input.color);\n return { node, update };\n}\n","import { Color, type ColorRepresentation, type Node } from 'three/webgpu';\nimport { Break, float, Fn, If, Loop, max, mix, select, time, uint, uniform, uniformArray, vec2, vec4 } from 'three/tsl';\nimport type { ForestTree } from '../forest';\nimport type { Tree } from '../tree';\nimport type { LiveTreeEffect } from './live';\nimport type { TreeEffectInput } from './mask';\nimport { EIGHT_DIRECTIONS, requireInput, texelAt, treeIdAt } from './screen';\nimport { treeIdOf } from './tree-id';\n\n/** Highlight settings. */\nexport interface TreeHighlightOptions {\n /** Colour the highlighted trees are tinted towards (default a warm yellow, '#ffe066'). */\n color?: ColorRepresentation;\n /** How far the trees are tinted towards `color`, 0..1 (default 0.25). */\n tint?: number;\n /** Brightness multiplier of the highlighted trees (default 1.25). */\n brightness?: number;\n /** Colour of the ring just outside the highlighted trees (default '#ffd23f'). */\n outlineColor?: ColorRepresentation;\n /** Width of the ring in pixels (default 2). */\n thickness?: number;\n /** Opacity of the whole Highlight, 0..1 (default 1). */\n strength?: number;\n /**\n * Pulse frequency in Hz: tint and brightness swing between their value and half of it (half the\n * brightening); the ring stays solid. Default 0 = no pulse.\n */\n pulse?: number;\n}\n\n/** The most trees highlighted at once; the rest of the list is ignored (with one console warning). */\nconst MAX_HIGHLIGHTED = 64;\n\n/**\n * The current Tree ID of a highlighted entry, or `undefined` to skip it: a removed or undrawn\n * Forest tree, a Tree that is disposed or in no scene, or anything that is not a Tree or Forest tree.\n */\nfunction idOfHighlighted(entry: Tree | ForestTree): number | undefined {\n if (!entry || typeof entry !== 'object') return undefined;\n if ('isTree' in entry) return entry.isTree && entry.parent !== null ? treeIdOf(entry) : undefined;\n if (!('slot' in entry) || !('owner' in entry)) return undefined;\n return treeIdOf(entry);\n}\n\n/**\n * Tree Effect: marks the trees in `highlighted` (Trees and Forest trees; mutable, read every frame)\n * by brightening and tinting their pixels and drawing a ring just outside them, the one Tree Effect\n * that also changes pixels next to a tree. At most 64 trees (the rest is ignored with one warning); removed, disposed\n * and undrawn trees are skipped. Needs the Tree ID input (`treeEffectsPass` with `{ treeId: true }`).\n */\nexport function treeHighlight(input: TreeEffectInput, highlighted: readonly (Tree | ForestTree)[], options: TreeHighlightOptions = {}): Node<'vec4'> {\n return liveTreeHighlight(input, highlighted, options).node;\n}\n\n/** {@link treeHighlight} with its settings as uniforms. */\nexport function liveTreeHighlight(\n input: TreeEffectInput,\n highlighted: readonly (Tree | ForestTree)[],\n options: TreeHighlightOptions = {},\n): LiveTreeEffect<TreeHighlightOptions> {\n const treeId = requireInput(\n 'treeHighlight',\n input.treeId,\n 'treeId',\n 'use treeEffectsPass(scene, camera, selection, { treeId: true }), or merge treeIdMRT() into your scene pass and pass its texture node',\n );\n\n const color = uniform(new Color());\n const outlineColor = uniform(new Color());\n const tint = uniform(0);\n const brightness = uniform(0);\n const thickness = uniform(0);\n const strength = uniform(0);\n const pulse = uniform(0);\n const update = (o: TreeHighlightOptions): void => {\n color.value.set(o.color ?? '#ffe066');\n outlineColor.value.set(o.outlineColor ?? '#ffd23f');\n tint.value = o.tint ?? 0.25;\n brightness.value = o.brightness ?? 1.25;\n thickness.value = o.thickness ?? 2;\n strength.value = o.strength ?? 1;\n pulse.value = o.pulse ?? 0;\n };\n update(options);\n\n // The IDs of the highlighted trees, refreshed once before every render (by whichever of the two\n // uniforms is updated first; the array is copied to its buffer after its own refresh).\n const count = uniform(0, 'uint');\n const ids = uniformArray(new Array<number>(MAX_HIGHLIGHTED).fill(0), 'uint');\n let refreshed = -1;\n let warned = false;\n const refresh = (renderId: number): void => {\n if (renderId === refreshed) return;\n refreshed = renderId;\n let n = 0;\n for (const entry of highlighted) {\n const id = idOfHighlighted(entry);\n if (id === undefined) continue;\n if (n === MAX_HIGHLIGHTED) {\n if (!warned) console.warn(`Highlight: at most ${MAX_HIGHLIGHTED} trees are highlighted at once; the rest are ignored`);\n warned = true;\n break;\n }\n ids.array[n++] = id;\n }\n ids.array.fill(0, n);\n count.value = n;\n };\n count.onRenderUpdate((frame) => {\n refresh(frame.renderId);\n return undefined;\n });\n ids.onRenderUpdate((frame) => refresh(frame.renderId));\n\n /** 1 where the tree drawn at `offset` px from this pixel is highlighted, else 0. */\n const isHighlighted = Fn(([offset]: [Node<'vec2'>]) => {\n const id = treeIdAt(treeId, texelAt(treeId, offset));\n const hit = float(0).toVar();\n If(id.notEqual(uint(0)), () => {\n Loop({ start: uint(0), end: count, type: 'uint', condition: '<' }, ({ i }) => {\n If((ids.element(i) as unknown as Node<'uint'>).equal(id), () => {\n hit.assign(1);\n Break();\n });\n });\n });\n return hit;\n });\n\n // The ring: pixels that are not highlighted themselves next to (at `thickness` px) one that is.\n const onHighlighted = isHighlighted(vec2(0));\n let besideHighlighted: Node<'float'> = float(0);\n for (const [x, y] of EIGHT_DIRECTIONS) besideHighlighted = max(besideHighlighted, isHighlighted(vec2(x, y).mul(thickness).round()));\n const ring = besideHighlighted.mul(float(1).sub(onHighlighted));\n\n // 1 without a pulse, else swinging between 1 and 0.5 with a sine.\n const swing = float(0.75).add(float(0.25).mul(time.mul(pulse).mul(2 * Math.PI).cos()));\n const lifted = input.color.rgb.mul(float(1).add(brightness.sub(1).mul(swing)));\n const marked = mix(lifted, color, tint.mul(swing).clamp(0, 1));\n const rgb = mix(input.color.rgb, marked, onHighlighted.mul(strength));\n const node = vec4(mix(rgb, outlineColor, ring.mul(strength)), input.color.a);\n // Nothing highlighted: the colour as it is.\n return { node: select(count.equal(uint(0)), input.color, node), update };\n}\n","import type { StyleName } from '../styles/registry';\nimport type { TreeColorGradeOptions } from './grade';\nimport type { LeafGlowOptions } from './glow';\nimport type { TreeHighlightOptions } from './highlight';\nimport type { TreeOutlineOptions } from './outline';\nimport type { InnerLinesOptions } from './inner-lines';\n\n/** A combination of Tree Effects; leave an effect out to skip it. `{}` = no effects. */\nexport interface TreeEffectsSettings {\n grade?: TreeColorGradeOptions;\n glow?: LeafGlowOptions;\n outline?: TreeOutlineOptions;\n innerLines?: InnerLinesOptions;\n /** Marks the TreeEffects' `highlighted` trees; never in a suggestion. */\n highlight?: TreeHighlightOptions;\n}\n\n/** The suggested combination of Tree Effects for each built-in Style. */\nexport const SUGGESTED_TREE_EFFECTS: Record<StyleName, TreeEffectsSettings> = {\n // Crisp facets: a dark ink line around and between the trees, ink lines on the clumps inside the\n // crown and slightly punchier colours.\n 'low-poly': {\n grade: { saturation: 1.15, contrast: 1.1 },\n innerLines: { color: '#18230f', thickness: 1, strength: 0.8 },\n outline: { color: '#18230f', thickness: 2, strength: 0.9, betweenTrees: true },\n },\n // Storybook look: soft glowing foliage, a warm tint, a hint of ink inside the crown and a soft\n // coloured outline.\n stylized: {\n grade: { saturation: 0.95, contrast: 1.08, tint: '#fff1e0' },\n glow: { color: '#fff6c8', intensity: 0.45, threshold: 0.3, radius: 8 },\n innerLines: { color: '#2b3a1c', thickness: 1, strength: 0.45, normalThreshold: 0.5 },\n outline: { color: '#2b3a1c', thickness: 2, strength: 0.6 },\n },\n // Natural: no ink; only a gentle grade (warmer, a touch more contrast) and a faint sunlit leaf glow.\n realistic: {\n grade: { exposure: 1.05, contrast: 1.08, saturation: 0.95, tint: '#fff5e6' },\n glow: { color: '#e8ffc0', intensity: 0.35, threshold: 0.12, radius: 4 },\n },\n};\n","import { RenderPipeline, type Camera, type Node, type Object3D, type Renderer, type Scene } from 'three/webgpu';\nimport type { StyleName } from '../styles/registry';\nimport { glowRadius, liveLeafGlow } from './glow';\nimport { liveTreeColorGrade } from './grade';\nimport type { LiveTreeEffect } from './live';\nimport type { TreeEffectInput } from './mask';\nimport { liveTreeHighlight } from './highlight';\nimport { liveTreeOutline } from './outline';\nimport { liveInnerLines } from './inner-lines';\nimport { treeEffectsPass, type TreeEffectsChannels, type TreeEffectsPass } from './pass';\nimport { SUGGESTED_TREE_EFFECTS, type TreeEffectsSettings } from './suggested';\nimport { readTreeId, treeFromId } from './tree-id';\nimport type { ForestTree } from '../forest';\nimport type { Tree } from '../tree';\n\n/**\n * Applies a combination of Tree Effects to `input` and returns the resulting colour node, for use in\n * your own post-processing pipeline (`pipeline.outputNode = applyTreeEffects(...)`, or feed it into\n * more effects). Order: colour grade, leaf glow, inner lines, outline, highlight (always on top).\n * Empty settings return `input.color`. `highlighted`: the trees the Highlight marks (mutable, read every frame).\n */\nexport function applyTreeEffects(input: TreeEffectInput, settings: TreeEffectsSettings, highlighted: readonly (Tree | ForestTree)[] = []): Node<'vec4'> {\n return liveTreeEffects(input, settings, highlighted).node;\n}\n\n/**\n * The shape of a combination: what its graph is built from (the effects that are on, the glow\n * radius, the outline's `betweenTrees` and the normal encoding of Inner Lines). Settings of the same\n * shape only differ in uniforms.\n */\nfunction shapeOf(settings: TreeEffectsSettings, input: TreeEffectInput): string {\n const outline = settings.outline ? (drawsBetweenTrees(settings) ? 'between' : 'outline') : null;\n const innerLines = settings.innerLines ? (input.normalEncoding ?? 'color') : null;\n return JSON.stringify([!!settings.grade, settings.glow ? glowRadius(settings.glow) : null, outline, innerLines, !!settings.highlight]);\n}\n\n/** Whether the outline is also drawn between trees: part of the shape, and it needs the Tree ID channel. */\nfunction drawsBetweenTrees(settings: TreeEffectsSettings): boolean {\n return settings.outline?.betweenTrees === true;\n}\n\n/** {@link applyTreeEffects} with every colour and number as a uniform; `update()` needs the same shape. */\nfunction liveTreeEffects(\n input: TreeEffectInput,\n settings: TreeEffectsSettings,\n highlighted: readonly (Tree | ForestTree)[],\n): LiveTreeEffect<TreeEffectsSettings> {\n const updates: ((settings: TreeEffectsSettings) => void)[] = [];\n let color = input.color;\n if (settings.grade) {\n const grade = liveTreeColorGrade({ color, mask: input.mask }, settings.grade);\n updates.push((s) => grade.update(s.grade!));\n color = grade.node;\n }\n if (settings.glow) {\n const glow = liveLeafGlow({ color, mask: input.mask }, settings.glow);\n updates.push((s) => glow.update(s.glow!));\n color = glow.node;\n }\n if (settings.innerLines) {\n const lines = liveInnerLines({ ...input, color }, settings.innerLines);\n updates.push((s) => lines.update(s.innerLines!));\n color = lines.node;\n }\n if (settings.outline) {\n const outline = liveTreeOutline({ ...input, color }, settings.outline);\n updates.push((s) => outline.update(s.outline!));\n color = outline.node;\n }\n // Highlight last, so it always sits on top.\n if (settings.highlight) {\n const highlight = liveTreeHighlight({ ...input, color }, highlighted, settings.highlight);\n updates.push((s) => highlight.update(s.highlight!));\n color = highlight.node;\n }\n return { node: color, update: (s) => updates.forEach((update) => update(s)) };\n}\n\n/** The suggested combination of a built-in Style, or the settings themselves; `null` = no effects. */\nexport type TreeEffectsChoice = StyleName | TreeEffectsSettings | null;\n\nfunction resolveEffects(choice: TreeEffectsChoice): TreeEffectsSettings {\n if (choice === null) return {};\n if (typeof choice !== 'string') return choice;\n const settings = (SUGGESTED_TREE_EFFECTS as Record<string, TreeEffectsSettings | undefined>)[choice];\n if (!settings) throw new Error(`No suggested Tree Effects for Style \"${choice}\"`);\n return settings;\n}\n\nexport interface TreeEffectsOptions {\n /** Which effects: a Style name (its suggested combination), custom settings, or `null` (none). Default: none. */\n effects?: TreeEffectsChoice;\n /**\n * The trees to outline (Trees, Forests, groups of them; mutable, read on every draw).\n * Default: every tree in the scene.\n */\n selection?: Object3D[];\n /**\n * Keeps the Tree ID channel on even when no effect needs it, for {@link TreeEffects.pick}.\n * Default: false (the channel is only rendered when an effect needs it). Whenever the Tree ID\n * channel is on (this option, `outline.betweenTrees`, `highlight`, or the low-poly suggestion),\n * the scene pass renders without MSAA: an integer target cannot be multisampled.\n */\n treeId?: boolean;\n /**\n * The trees the Highlight marks (`effects: { highlight: {...} }`): Trees and Forest trees, at most\n * 64; mutable, read every frame, so hover and selection changes never recompile. Default: none\n * (a new empty list, see {@link TreeEffects.highlighted}).\n */\n highlighted?: (Tree | ForestTree)[];\n}\n\n/**\n * The extra channels the scene pass needs for `settings` (with the `treeId` option). Only this\n * set decides the scene pass's MRT: settings that need the same channels keep it.\n */\nfunction channelsFor(settings: TreeEffectsSettings, options: TreeEffectsOptions): TreeEffectsChannels {\n return {\n treeId: options.treeId === true || drawsBetweenTrees(settings) || !!settings.highlight,\n normal: !!settings.innerLines,\n };\n}\n\n/** A key that is equal for equal sets of channels. */\nfunction channelsKey(channels: TreeEffectsChannels): string {\n return Object.entries(channels)\n .filter(([, on]) => on === true)\n .map(([name]) => name)\n .sort()\n .join();\n}\n\n/**\n * A ready-made post-processing pipeline (`RenderPipeline`) with the Tree Effects: render with\n * `effects.render()` instead of `renderer.render(scene, camera)`. Switch the combination with\n * `effects.set('stylized')` (e.g. a preview). For your own pipeline, use {@link treeEffectsPass}\n * and {@link applyTreeEffects} instead.\n */\nexport class TreeEffects {\n readonly pipeline: RenderPipeline;\n /** The trees the Highlight marks (the `highlighted` option, or an empty list): change it in place. */\n readonly highlighted: (Tree | ForestTree)[];\n private nodes: Node[] = [];\n private current: TreeEffectsSettings = {};\n private graph: { shape: string; effects: LiveTreeEffect<TreeEffectsSettings> } | null = null;\n private input!: { channels: string; pass: TreeEffectsPass };\n\n constructor(\n private readonly renderer: Renderer,\n private readonly scene: Scene,\n private readonly camera: Camera,\n private readonly options: TreeEffectsOptions = {},\n ) {\n this.pipeline = new RenderPipeline(renderer);\n this.highlighted = options.highlighted ?? [];\n this.set(options.effects ?? null);\n }\n\n /**\n * The scene pass (colour + tree mask, plus the channels the settings need, such as the Tree ID).\n *\n * It is replaced by a new one (a new object, the old one disposed) when {@link set} needs another\n * set of channels, and only then; read it again after such a `set()` rather than keeping it.\n * Swapping only the MRT of one PassNode is not feasible with three: a PassNode can add targets\n * (`getTexture`) but has no way to remove one, and its sample count is fixed per target, so\n * turning a channel off (or the Tree ID off, which brings MSAA back) needs a new pass. Either way\n * the scene's materials recompile, because the MRT changes; settings that need the same channels\n * keep this pass and its MRT.\n */\n get scenePass(): TreeEffectsPass {\n return this.input.pass;\n }\n\n /** The active combination (`{}` = none). */\n get settings(): TreeEffectsSettings {\n return this.current;\n }\n\n /**\n * Switches to a Style's suggested combination, custom settings, or none (`null`). With the same\n * effects on (and the same glow radius) only the colours and numbers change, without a recompile;\n * otherwise a new graph is built and the old one freed.\n */\n set(effects: TreeEffectsChoice): void {\n this.current = resolveEffects(effects);\n const channels = channelsFor(this.current, this.options);\n const key = channelsKey(channels);\n if (this.input?.channels !== key) {\n // Other channels: a new scene pass (new MRT), and a new graph that reads it.\n this.disposeNodes();\n this.input?.pass.pass.dispose();\n this.input = { channels: key, pass: treeEffectsPass(this.scene, this.camera, this.options.selection ?? null, channels) };\n this.graph = null;\n }\n const shape = shapeOf(this.current, this.scenePass);\n if (this.graph?.shape === shape) {\n this.graph.effects.update(this.current);\n return;\n }\n this.disposeNodes();\n const live = liveTreeEffects(this.scenePass, this.current, this.highlighted);\n this.graph = { shape, effects: live };\n this.nodes = collectEffectNodes(live.node, this.scenePass.color);\n this.pipeline.outputNode = live.node;\n this.pipeline.needsUpdate = true;\n }\n\n /**\n * GPU picking: the Tree or Forest tree under a point of the canvas (CSS pixels from its top left\n * corner, as `event.offsetX/offsetY`) in the last render, or `undefined` where no tree is drawn.\n * Needs the Tree ID channel: throws when it is off (create the effects with `treeId: true`).\n */\n pick(x: number, y: number): Promise<Tree | ForestTree | undefined> {\n const { pass, treeId } = this.scenePass;\n if (!treeId) throw new Error('TreeEffects.pick() needs the Tree ID channel: create the effects with the `treeId: true` option');\n return readTreeId(this.renderer, pass, x, y).then(treeFromId);\n }\n\n /** Renders the scene with the effects (call instead of `renderer.render(scene, camera)`). */\n render(): void {\n this.pipeline.render();\n }\n\n dispose(): void {\n this.disposeNodes();\n this.scenePass.pass.dispose();\n this.pipeline.dispose();\n }\n\n private disposeNodes(): void {\n for (const node of this.nodes) node.dispose();\n this.nodes = [];\n }\n}\n\n/** The render-target owning nodes (blur) in an effects graph, to dispose them on change. */\nfunction collectEffectNodes(output: Node, stop: Node): Node[] {\n const found = new Set<Node>();\n const visit = (node: Node, seen: Set<Node>): void => {\n if (seen.has(node) || node === stop) return;\n seen.add(node);\n const n = node as Node & { isGaussianBlurNode?: boolean };\n if (n.isGaussianBlurNode) found.add(node);\n for (const child of node.getChildren()) visit(child as Node, seen);\n };\n visit(output, new Set());\n return [...found];\n}\n\n/** Shorthand for `new TreeEffects(renderer, scene, camera, options)`. */\nexport function createTreeEffects(renderer: Renderer, scene: Scene, camera: Camera, options?: TreeEffectsOptions): TreeEffects {\n return new TreeEffects(renderer, scene, camera, options);\n}\n"],"mappings":";;;;;AAIA,IAAa,YAAY;;;;;AASzB,SAAgB,WAAW,UAAwD;CACjF,MAAM,OAAgB,UAAU,SAAS;CACzC,OAAO,SAAS,UAAU,SAAS,YAAY,SAAS,UAAU,OAAO;AAC3E;AAEA,SAAS,WAAW,QAAyB,WAAyC;CACpF,KAAK,IAAI,IAAI,QAAQ,GAAG,IAAI,EAAE,QAAQ,IAAI,UAAU,SAAS,CAAC,GAAG,OAAO;CACxE,OAAO;AACT;;;;;;;;;;AAWA,SAAgB,eAAe,YAAwC,MAAoB;CACzF,OAAO,QAAQ,IAAI,QAAQ,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,gBAAgB,OAAO,SAAS;EACtE,MAAM,OAAO,WAAW,MAAM,QAAQ;EACtC,MAAM,WAAW,SAAS,SAAS,cAAc,QAAQ,WAAW,MAAM,QAAQ,SAAS;EAC3F,KAAK,MAAM,IAAI,OAAO,IAAI,GAAG,SAAS,WAAW,IAAI,GAAG,WAAW,IAAI,GAAG,CAAC;CAE7E,CAAC;AACH;;;;;;AAOA,SAAgB,YAAY,YAAwC,MAAe;CACjF,MAAM,OAAO,IAAI,GAAG,YAAY,eAAe,SAAS,EAAE,CAAC;CAC3D,KAAK,cAAc,WAAW,GAAU,CAAC;CACzC,OAAO;AACT;;;AC3CA,IAAa,UAAU;AAIvB,IAAM,SAAS;AACf,IAAI,SAAS;AACb,IAAM,0BAAU,IAAI,QAAsB;AAC1C,IAAM,4BAAY,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C;CAChB;AACF;;AAGA,SAAS,mBAAmB,QAAc,MAAoB;CAC5D,MAAM,wBAAQ,IAAI,IAAU;CAC5B,MAAM,SAAS,MAAY,SAA0B;EACnD,IAAI,KAAK,IAAI,IAAI,KAAK,SAAS,MAAM;EACrC,KAAK,IAAI,IAAI;EAEb,IAAIA,KAAE,oBAAoB,MAAM,IAAI,IAAI;EACxC,KAAK,MAAM,SAAS,KAAK,YAAY,GAAG,MAAM,OAAe,IAAI;CACnE;CACA,MAAM,wBAAQ,IAAI,IAAI,CAAC;CACvB,OAAO,CAAC,GAAG,KAAK;AAClB;;AAGA,SAAgB,kBAAkB,UAAoB,OAAc,QAAgB,SAA2C;CAC7H,OAAO,IAAI,YAAY,UAAU,OAAO,QAAQ,OAAO;AACzD"}
@@ -41,6 +41,8 @@ export declare class ForestTree implements ForestTreeTraits {
41
41
  readonly windPhase: number;
42
42
  /** @internal Slot in the Variant's instance buffers. */
43
43
  slot: number;
44
+ /** @internal The Variant drawing this tree, null once it is removed. */
45
+ owner: ForestVariant | null;
44
46
  private growthValue;
45
47
  private seasonValue;
46
48
  /** @internal Use {@link Forest.addTree}. */
@@ -1 +1 @@
1
- {"version":3,"file":"Forest.d.ts","sourceRoot":"","sources":["../../src/forest/Forest.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EAGd,KAAK,EAGL,aAAa,EAMb,KAAK,wBAAwB,EAC9B,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC9F,OAAO,EAAmD,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAO9F,OAAO,EAAgB,KAAK,cAAc,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,EAAa,IAAI,EAAe,YAAY,EAAE,KAAK,UAAU,EAAE,MAAM,SAAS,CAAC;AAEtF,OAAO,EAOL,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACtB,MAAM,a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AQvD,mGAAmG;IACnG,MAAM,CAAC,YAAY,EAAE;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,UAAU,GAAG,SAAS;IAKtF,mGAAmG;IACnG,aAAa,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,mBAAmB;IAMtE,yGAAyG;IACzG,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,IAAI,MAAM,CAAC,KAAK,EAAE,MAAM,EAGvB;IAED,yGAAyG;IACzG,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,IAAI,MAAM,CAAC,KAAK,EAAE,MAAM,EAGvB;IAED;;;;OAIG;IACH,IAAI,YAAY,IAAI,MAAM,GAAG,IAAI,CAEhC;IAED,IAAI,YAAY,CAAC,KAAK,EAAE,MAAM,EAE7B;IAED;;;;OAIG;IACH,IAAI,YAAY,IAAI,sBAAsB,GAAG,IAAI,CAEhD;IAED,IAAI,YAAY,CAAC,KAAK,EAAE,OAAO,CAAC,sBAAsB,CAAC,EAEtD;IAED;;;OAGG;IACH,IAAI,gBAAgB,IAAI,gBAAgB,CAEvC;IAED;;;OAGG;IACH,IAAI,iBAAiB,IAAI,MAAM,GAAG,IAAI,CAErC;IAED,IAAI,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAElC;IAED,gHAAgH;IACvG,OAAO,IAAI,IAAI;CAMzB"}
@@ -3674,6 +3674,8 @@ var ForestTree = class {
3674
3674
  windPhase;
3675
3675
  /** @internal Slot in the Variant's instance buffers. */
3676
3676
  slot = -1;
3677
+ /** @internal The Variant drawing this tree, null once it is removed. */
3678
+ owner = null;
3677
3679
  growthValue;
3678
3680
  seasonValue;
3679
3681
  /** @internal Use {@link Forest.addTree}. */
@@ -3843,6 +3845,7 @@ var ForestVariant = class {
3843
3845
  add(tree) {
3844
3846
  if (this.trees.length === this.capacity) this.allocate(this.capacity * 2);
3845
3847
  tree.slot = this.trees.length;
3848
+ tree.owner = this;
3846
3849
  this.trees.push(tree);
3847
3850
  this.write(tree);
3848
3851
  this.setCount();
@@ -3856,6 +3859,7 @@ var ForestVariant = class {
3856
3859
  this.write(last);
3857
3860
  }
3858
3861
  tree.slot = -1;
3862
+ tree.owner = null;
3859
3863
  this.setCount();
3860
3864
  }
3861
3865
  /** @internal Writes one tree's transform and state into its instance slot. */
@@ -4133,4 +4137,4 @@ function createForest(definition, placements = [], options = {}) {
4133
4137
  }
4134
4138
  export { treeScale as A, hexToLinear as B, loadTexture as C, groundTintAmount as D, textureReady as E, KEYFRAME_EPSILON as F, seasonShift as G, leafSeasonAttribute as H, evaluateSeason as I, woodSeasonAttribute as J, segmentWeight as K, fruitSeason as L, hashTreeData as M, crownDistance as N, clampGrowth as O, crownNormal as P, fruitSeasonAttribute as R, getTextureOptions as S, setTextureOptions as T, partSeasonAt as U, leafSeason as V, sampleTrack as W, createRandom as X, wrapSeason as Y, createBarkMaterial as _, forestTreeKey as a, BARK_REPEAT as b, Tree as c, sceneWind as d, applySeasonToLeafMaterial as f, assertWebGPURenderer as g, UnsupportedRendererError as h, ForestVariant as i, hashGeometry as j, growPositions as k, WindResponse as l, createSeasonNodes as m, Forest as n, loadStyle as o, createFruitSeasonNodes as p, srgbToLinear as q, ForestTree as r, createTree as s, createForest as t, Wind as u, createLeafMaterial as v, resolveTextureUrl as w, DEFAULT_TEXTURE_BASE_PATH as x, isFlatShading as y, fruitTracks as z };
4135
4139
 
4136
- //# sourceMappingURL=forest-ChEaWJrf.js.map
4140
+ //# sourceMappingURL=forest-lg61rhKM.js.map