@casmo/tree.js 0.3.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +775 -4
- package/dist/effects/custom.d.ts +62 -0
- package/dist/effects/custom.d.ts.map +1 -0
- package/dist/effects/effects.d.ts +92 -6
- package/dist/effects/effects.d.ts.map +1 -1
- package/dist/effects/glow.d.ts +5 -0
- package/dist/effects/glow.d.ts.map +1 -1
- package/dist/effects/grade.d.ts +3 -0
- package/dist/effects/grade.d.ts.map +1 -1
- package/dist/effects/highlight.d.ts +35 -0
- package/dist/effects/highlight.d.ts.map +1 -0
- package/dist/effects/index.d.ts +7 -1
- package/dist/effects/index.d.ts.map +1 -1
- package/dist/effects/inner-lines.d.ts +39 -0
- package/dist/effects/inner-lines.d.ts.map +1 -0
- package/dist/effects/live.d.ts +12 -0
- package/dist/effects/live.d.ts.map +1 -0
- package/dist/effects/mask.d.ts +32 -12
- package/dist/effects/mask.d.ts.map +1 -1
- package/dist/effects/outline.d.ts +12 -0
- package/dist/effects/outline.d.ts.map +1 -1
- package/dist/effects/pass.d.ts +27 -0
- package/dist/effects/pass.d.ts.map +1 -0
- package/dist/effects/screen.d.ts +31 -0
- package/dist/effects/screen.d.ts.map +1 -0
- package/dist/effects/suggested.d.ts +5 -0
- package/dist/effects/suggested.d.ts.map +1 -1
- package/dist/effects/tree-id.d.ts +50 -0
- package/dist/effects/tree-id.d.ts.map +1 -0
- package/dist/effects-qHx_8Dlk.js +1052 -0
- package/dist/effects-qHx_8Dlk.js.map +1 -0
- package/dist/effects.js +3 -249
- package/dist/forest/Forest.d.ts +82 -4
- package/dist/forest/Forest.d.ts.map +1 -1
- package/dist/forest/forest-lod.d.ts +70 -0
- package/dist/forest/forest-lod.d.ts.map +1 -0
- package/dist/forest/impostor-material.d.ts +106 -0
- package/dist/forest/impostor-material.d.ts.map +1 -0
- package/dist/forest/impostor-season.d.ts +13 -0
- package/dist/forest/impostor-season.d.ts.map +1 -0
- package/dist/forest/impostor.d.ts +105 -0
- package/dist/forest/impostor.d.ts.map +1 -0
- package/dist/forest/index.d.ts +1 -0
- package/dist/forest/index.d.ts.map +1 -1
- package/dist/forest/levels.d.ts +144 -0
- package/dist/forest/levels.d.ts.map +1 -0
- package/dist/forest/lod.d.ts +106 -0
- package/dist/forest/lod.d.ts.map +1 -0
- package/dist/forest/nodes.d.ts +42 -1
- package/dist/forest/nodes.d.ts.map +1 -1
- package/dist/forest/octahedral.d.ts +33 -0
- package/dist/forest/octahedral.d.ts.map +1 -0
- package/dist/{forest-ChEaWJrf.js → forest-CM5DrklM.js} +1727 -340
- package/dist/forest-CM5DrklM.js.map +1 -0
- package/dist/generator/fruit.d.ts +2 -0
- package/dist/generator/fruit.d.ts.map +1 -1
- package/dist/generator/index.d.ts +1 -0
- package/dist/generator/index.d.ts.map +1 -1
- package/dist/generator/light.d.ts +36 -0
- package/dist/generator/light.d.ts.map +1 -0
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/dist/materials/crown-nodes.d.ts +5 -0
- package/dist/materials/crown-nodes.d.ts.map +1 -1
- package/dist/materials/leaf-translucency-model.d.ts +6 -1
- package/dist/materials/leaf-translucency-model.d.ts.map +1 -1
- package/dist/materials/material-features.d.ts +12 -0
- package/dist/materials/material-features.d.ts.map +1 -1
- package/dist/materials/shader-hooks.d.ts +155 -0
- package/dist/materials/shader-hooks.d.ts.map +1 -0
- package/dist/motion-Qd7xjeZM.js +276 -0
- package/dist/motion-Qd7xjeZM.js.map +1 -0
- package/dist/nodes-DxgTyF9B.js +436 -0
- package/dist/nodes-DxgTyF9B.js.map +1 -0
- package/dist/react/Forest.d.ts +17 -3
- package/dist/react/Forest.d.ts.map +1 -1
- package/dist/react/ScenePipeline.d.ts +63 -0
- package/dist/react/ScenePipeline.d.ts.map +1 -0
- package/dist/react/SceneShaderHooks.d.ts +25 -0
- package/dist/react/SceneShaderHooks.d.ts.map +1 -0
- package/dist/react/Tree.d.ts +9 -2
- package/dist/react/Tree.d.ts.map +1 -1
- package/dist/react/Weather.d.ts +45 -0
- package/dist/react/Weather.d.ts.map +1 -0
- package/dist/react/Wind.d.ts +12 -1
- package/dist/react/Wind.d.ts.map +1 -1
- package/dist/react/index.d.ts +7 -1
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react.js +347 -10
- package/dist/react.js.map +1 -1
- package/dist/renderer/index.d.ts +6 -0
- package/dist/renderer/index.d.ts.map +1 -1
- package/dist/scene/antialias.d.ts +35 -0
- package/dist/scene/antialias.d.ts.map +1 -0
- package/dist/scene/ao.d.ts +46 -0
- package/dist/scene/ao.d.ts.map +1 -0
- package/dist/scene/bloom.d.ts +19 -0
- package/dist/scene/bloom.d.ts.map +1 -0
- package/dist/scene/fog.d.ts +49 -0
- package/dist/scene/fog.d.ts.map +1 -0
- package/dist/scene/godrays.d.ts +37 -0
- package/dist/scene/godrays.d.ts.map +1 -0
- package/dist/scene/index.d.ts +14 -0
- package/dist/scene/index.d.ts.map +1 -0
- package/dist/scene/motion-blur.d.ts +23 -0
- package/dist/scene/motion-blur.d.ts.map +1 -0
- package/dist/scene/pipeline.d.ts +109 -0
- package/dist/scene/pipeline.d.ts.map +1 -0
- package/dist/scene/settings.d.ts +36 -0
- package/dist/scene/settings.d.ts.map +1 -0
- package/dist/scene/stack.d.ts +25 -0
- package/dist/scene/stack.d.ts.map +1 -0
- package/dist/scene/stage.d.ts +52 -0
- package/dist/scene/stage.d.ts.map +1 -0
- package/dist/scene/suggested.d.ts +12 -0
- package/dist/scene/suggested.d.ts.map +1 -0
- package/dist/scene/tone-mapping.d.ts +20 -0
- package/dist/scene/tone-mapping.d.ts.map +1 -0
- package/dist/scene/velocity.d.ts +34 -0
- package/dist/scene/velocity.d.ts.map +1 -0
- package/dist/scene.js +889 -0
- package/dist/scene.js.map +1 -0
- package/dist/season/nodes.d.ts +13 -0
- package/dist/season/nodes.d.ts.map +1 -1
- package/dist/shader-hooks-BFRtlWGI.js +275 -0
- package/dist/shader-hooks-BFRtlWGI.js.map +1 -0
- package/dist/tree/Tree.d.ts +8 -3
- package/dist/tree/Tree.d.ts.map +1 -1
- package/dist/tree/index.d.ts.map +1 -1
- package/dist/weather/index.d.ts +3 -0
- package/dist/weather/index.d.ts.map +1 -0
- package/dist/weather/shared.d.ts +43 -0
- package/dist/weather/shared.d.ts.map +1 -0
- package/dist/weather/snow.d.ts +87 -0
- package/dist/weather/snow.d.ts.map +1 -0
- package/dist/weather/wetness.d.ts +75 -0
- package/dist/weather/wetness.d.ts.map +1 -0
- package/dist/weather.js +288 -0
- package/dist/weather.js.map +1 -0
- package/dist/wind/Wind.d.ts +100 -5
- package/dist/wind/Wind.d.ts.map +1 -1
- package/dist/wind/burst.d.ts +28 -0
- package/dist/wind/burst.d.ts.map +1 -0
- package/dist/wind/index.d.ts +3 -2
- package/dist/wind/index.d.ts.map +1 -1
- package/dist/wind/motion.d.ts +30 -0
- package/dist/wind/motion.d.ts.map +1 -0
- package/dist/wind/node.d.ts +17 -3
- package/dist/wind/node.d.ts.map +1 -1
- package/package.json +9 -1
- package/dist/effects.js.map +0 -1
- package/dist/forest-ChEaWJrf.js.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effects-qHx_8Dlk.js","names":["nextId","n"],"sources":["../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/custom.ts","../src/effects/effects.ts"],"sourcesContent":["import { NearestFilter, NoColorSpace, RedIntegerFormat, UnsignedIntType, Vector2, type BufferAttribute, type MRTNode, type Node, type Object3D, type PassNode, type Renderer, type Texture } from 'three/webgpu';\nimport { mrt, select, uniform } from 'three/tsl';\nimport { instanceSlot } from '../forest/nodes';\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, instanced or drawing a Detail Level (the shader adds the tree's slot), 0 for\n * 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) || v.levels?.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 slot, at every Detail Level (the instance index on the instanced meshes, the slot from\n * the level list on a Detail Level mesh). 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(instanceSlot())) 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 type { Node } from 'three/webgpu';\nimport type { LiveTreeEffect } from './live';\nimport type { TreeEffectInput } from './mask';\nimport type { TreeEffectsChannels } from './pass';\nimport type { TreeEffectsSettings } from './suggested';\n\n/** A built-in Tree Effect, by its key in {@link TreeEffectsSettings}. */\nexport type TreeEffectName = keyof TreeEffectsSettings;\n\n/** The order the built-in Tree Effects run in (the Highlight last of them, on top). */\nexport const TREE_EFFECT_ORDER: readonly TreeEffectName[] = ['grade', 'glow', 'innerLines', 'outline', 'highlight'];\n\n/** Where a custom Tree Effect runs: right before a built-in Tree Effect, or `'end'`: after all of them. */\nexport type TreeEffectPlace = TreeEffectName | 'end';\n\n/**\n * A Tree Effect written by the app, for `TreeEffects.addEffect()`. It is built the way the built-in\n * ones are: on the colour so far and the tree mask, returning its colour node and an `update()`\n * that changes its uniforms live (no new graph, no recompile).\n */\nexport interface CustomTreeEffect<Options = undefined> {\n /**\n * Runs right before this built-in Tree Effect, whether that one is on or not, or with `'end'` after\n * every built-in Tree Effect, the Highlight too (in the Scene Pipeline still before the Scene\n * Effects); custom effects at the same place run in the order they were added. Default\n * `'highlight'`: after every other built-in effect, and under the Highlight.\n */\n before?: TreeEffectPlace;\n /**\n * The optional channels the effect reads (`treeId`, `normal`): the scene pass adds them (ADR 0009)\n * and they are in the effect's input. Undeclared channels are never in its input, even when a\n * built-in effect has them on. Default: none (colour, tree mask, depth and camera only).\n */\n channels?: TreeEffectsChannels;\n /**\n * Builds the effect. `input.color` is the colour so far (the scene colour, or the result of the\n * effects before this one); `input.mask` is the tree mask: r = any tree, g = leaves only,\n * b = selected trees. Called again with the latest options whenever the graph is rebuilt.\n */\n build(input: TreeEffectInput, options: Options): LiveTreeEffect<Options>;\n}\n\n/** The options argument of `addEffect`: optional when the effect's options may be `undefined`. */\nexport type CustomTreeEffectOptions<Options> = undefined extends Options ? [options?: Options] : [options: Options];\n\ninterface Entry {\n effect: CustomTreeEffect<unknown>;\n options: unknown;\n id: number;\n live: LiveTreeEffect<unknown> | null;\n}\n\nlet nextId = 1;\n\n/**\n * Internal: the custom Tree Effects of a pipeline (`TreeEffects`, the Scene Pipeline) with their\n * latest options. It decides their part of the graph's shape and of the scene pass's channels, and\n * builds them into a graph at their places.\n */\nexport class CustomTreeEffectList {\n private entries: Entry[] = [];\n\n /** The custom effects, in the order they were added. */\n get effects(): readonly CustomTreeEffect<never>[] {\n return this.entries.map((entry) => entry.effect as CustomTreeEffect<never>);\n }\n\n add<Options>(effect: CustomTreeEffect<Options>, options: Options): void {\n if (this.find(effect)) throw new Error('This custom Tree Effect is already added; use updateEffect() to change its options');\n this.entries.push({ effect: effect as CustomTreeEffect<unknown>, options, id: nextId++, live: null });\n }\n\n /** Stores the options (used on rebuilds) and sets them on the built effect. */\n update<Options>(effect: CustomTreeEffect<Options>, options: Options): void {\n const entry = this.find(effect);\n if (!entry) throw new Error('This custom Tree Effect is not added; add it with addEffect() first');\n entry.options = options;\n entry.live?.update(options);\n }\n\n /** Whether the effect was there. */\n remove(effect: CustomTreeEffect<never>): boolean {\n const entry = this.find(effect);\n if (entry) this.entries.splice(this.entries.indexOf(entry), 1);\n return !!entry;\n }\n\n /** The channels the custom effects declare. */\n channels(): TreeEffectsChannels {\n return {\n treeId: this.entries.some((entry) => entry.effect.channels?.treeId === true),\n normal: this.entries.some((entry) => entry.effect.channels?.normal === true),\n };\n }\n\n /** Their part of a graph's shape: which effects, in which order and at which places. */\n shape(): string {\n return this.entries.map((entry) => `${entry.id}@${placeOf(entry.effect)}`).join();\n }\n\n /** Builds the custom effects placed before `name` (or at the `'end'`) onto `input.color` and returns the resulting colour. */\n buildBefore(name: TreeEffectPlace, input: TreeEffectInput): Node<'vec4'> {\n let color = input.color;\n for (const entry of this.entries) {\n if (placeOf(entry.effect) !== name) continue;\n entry.live = entry.effect.build(inputFor(entry.effect, { ...input, color }), entry.options);\n color = entry.live.node;\n }\n return color;\n }\n\n private find(effect: CustomTreeEffect<never>): Entry | undefined {\n return this.entries.find((entry) => entry.effect === effect);\n }\n}\n\nfunction placeOf(effect: CustomTreeEffect<never>): TreeEffectPlace {\n return effect.before ?? 'highlight';\n}\n\n/** The input an effect may read: colour, mask, depth and camera, and only the channels it declares. */\nfunction inputFor(effect: CustomTreeEffect<never>, input: TreeEffectInput): TreeEffectInput {\n const { treeId, normal, normalEncoding, ...always } = input;\n return {\n ...always,\n ...(effect.channels?.treeId && treeId && { treeId }),\n ...(effect.channels?.normal && normal && { normal, normalEncoding }),\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 { CustomTreeEffectList, type CustomTreeEffect, type CustomTreeEffectOptions, type TreeEffectPlace } from './custom';\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 */\nexport function treeEffectsShape(settings: TreeEffectsSettings, input: TreeEffectInput, custom?: CustomTreeEffectList): string {\n const outline = settings.outline ? (drawsBetweenTrees(settings) ? 'between' : 'outline') : null;\n const innerLines = settings.innerLines ? (input.normalEncoding ?? 'color') : null;\n const shape = [!!settings.grade, settings.glow ? glowRadius(settings.glow) : null, outline, innerLines, !!settings.highlight];\n const customShape = custom?.shape();\n return JSON.stringify(customShape ? [...shape, customShape] : shape);\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/**\n * {@link applyTreeEffects} with every colour and number as a uniform; `update()` needs the same shape.\n * Internal (not in the /effects index): shared with the Scene Pipeline (`src/scene`). `custom`: the\n * app's own Tree Effects, built in at their places (their `update()` is the list's, not this one's).\n */\nexport function liveTreeEffects(\n input: TreeEffectInput,\n settings: TreeEffectsSettings,\n highlighted: readonly (Tree | ForestTree)[],\n custom?: CustomTreeEffectList,\n): LiveTreeEffect<TreeEffectsSettings> {\n const updates: ((settings: TreeEffectsSettings) => void)[] = [];\n let color = input.color;\n const before = (name: TreeEffectPlace): void => {\n if (custom) color = custom.buildBefore(name, { ...input, color });\n };\n before('grade');\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 before('glow');\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 before('innerLines');\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 before('outline');\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 before('highlight');\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 before('end');\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\n/** The settings of a choice; throws for an unknown Style. Internal, shared with the Scene Pipeline. */\nexport function resolveTreeEffects(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 and the channels\n * the custom effects declare). Only this set decides the scene pass's MRT: settings that need the\n * same channels keep it.\n */\nexport function channelsFor(\n settings: TreeEffectsSettings,\n options: Pick<TreeEffectsOptions, 'treeId'>,\n custom?: CustomTreeEffectList,\n): TreeEffectsChannels {\n const declared = custom?.channels();\n return {\n treeId: options.treeId === true || drawsBetweenTrees(settings) || !!settings.highlight || declared?.treeId === true,\n normal: !!settings.innerLines || declared?.normal === true,\n };\n}\n\n/** A key that is equal for equal sets of channels. */\nexport function channelsKey(channels: object): 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 readonly custom = new CustomTreeEffectList();\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 = resolveTreeEffects(effects);\n this.rebuild();\n }\n\n /** The app's own Tree Effects, in the order they were added (see {@link addEffect}). */\n get customEffects(): readonly CustomTreeEffect<never>[] {\n return this.custom.effects;\n }\n\n /**\n * Adds a Tree Effect of the app's own (see {@link CustomTreeEffect}) with its options, at the place\n * it names among the built-in effects. It stays through {@link set} until {@link removeEffect}.\n * Builds a new graph, and a new scene pass if it declares a channel that is not on yet.\n */\n addEffect<Options>(effect: CustomTreeEffect<Options>, ...[options]: CustomTreeEffectOptions<Options>): void {\n this.custom.add(effect, options as Options);\n this.rebuild();\n }\n\n /** Changes the options of an added custom effect live, through its `update()` (no new graph, no recompile). */\n updateEffect<Options>(effect: CustomTreeEffect<Options>, options: Options): void {\n this.custom.update(effect, options);\n }\n\n /** Removes a custom effect (nothing happens if it is not added); its channels go when nothing else needs them. */\n removeEffect<Options>(effect: CustomTreeEffect<Options>): void {\n if (this.custom.remove(effect as CustomTreeEffect<never>)) this.rebuild();\n }\n\n /** Brings the scene pass and the graph in line with the settings and the custom effects. */\n private rebuild(): void {\n const channels = channelsFor(this.current, this.options, this.custom);\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 = treeEffectsShape(this.current, this.scenePass, this.custom);\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, this.custom);\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. */\nexport function 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":";;;;;;;AAQA,IAAa,UAAU;AAIvB,IAAM,SAAS;AACf,IAAIA,WAAS;AACb,IAAM,0BAAU,IAAI,QAAsB;AAC1C,IAAM,4BAAY,IAAI,IAA2B;AACjD,IAAM,aAAa,IAAI,sBAA8B,OAAO,UAAU,OAAO,EAAE,CAAC;AAahF,IAAM,0BAAU,IAAI,QAAgC;;AAEpD,IAAM,SAAkB,CAAC;AACzB,IAAM,cAAc,IAAI,sBAA6B,UAAU,OAAO,OAAO,OAAO,QAAQ,KAAK,GAAG,CAAC,CAAC;AAEtG,SAAS,QAAQ,OAAuB;CACtC,IAAIA,WAAS,QAAQ,IAAI,QAAQ,MAAM,IAAI,WAAW,qEAAqE;CAC3H,MAAM,OAAOA;CACb,YAAU;CACV,OAAO;AACT;AAEA,SAAS,SAAS,MAAoB;CACpC,IAAI,KAAK,QAAQ,IAAI,IAAI;CACz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B,SAA2C;CAC7H,OAAO,IAAI,YAAY,UAAU,OAAO,QAAQ,OAAO;AACzD"}
|
package/dist/effects.js
CHANGED
|
@@ -1,249 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
// src/effects/mask.ts
|
|
5
|
-
/** Name of the tree mask output in a pass's MRT (`scenePass.getTextureNode(TREE_MASK)`). */
|
|
6
|
-
var TREE_MASK = "treeMask";
|
|
7
|
-
/**
|
|
8
|
-
* Which tree part a material draws: 'bark', 'leaves' or 'fruit' for tree.js materials (and their clones),
|
|
9
|
-
* `null` for anything else. Tree Effects only change the pixels drawn by these materials.
|
|
10
|
-
*/
|
|
11
|
-
function treePartOf(material) {
|
|
12
|
-
const part = material?.userData.treePart;
|
|
13
|
-
return part === "bark" || part === "leaves" || part === "fruit" ? part : null;
|
|
14
|
-
}
|
|
15
|
-
function isSelected(object, selection) {
|
|
16
|
-
for (let o = object; o; o = o.parent) if (selection.includes(o)) return true;
|
|
17
|
-
return false;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* TSL node: the tree mask value of the object being drawn, `vec4(tree, leaves, selected, 1)`:
|
|
21
|
-
* r = 1 on tree pixels (bark, leaves and Fruit), g = 1 on leaf pixels, b = 1 on pixels of selected trees (the outline's
|
|
22
|
-
* selection), 0 elsewhere. A per-object uniform decided from the drawn material
|
|
23
|
-
* ({@link treePartOf}), so no tree material is changed and every other object writes 0.
|
|
24
|
-
*
|
|
25
|
-
* `selection`: the selected tree objects (Trees, Forests, any ancestor of tree meshes), read on
|
|
26
|
-
* every draw, so it may be changed in place. `null` (default) selects every tree.
|
|
27
|
-
*/
|
|
28
|
-
function createTreeMask(selection = null) {
|
|
29
|
-
return uniform(new Vector4(0, 0, 0, 1)).onObjectUpdate((frame, self) => {
|
|
30
|
-
const part = treePartOf(frame.material);
|
|
31
|
-
const selected = part !== null && (selection === null || isSelected(frame.object, selection));
|
|
32
|
-
self.value.set(part ? 1 : 0, part === "leaves" ? 1 : 0, selected ? 1 : 0, 1);
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* The MRT output that renders the tree mask ({@link createTreeMask}) next to the colour. Merge it
|
|
37
|
-
* into the MRT of your own scene pass: `scenePass.setMRT(mrt({ output, normal: normalView }).merge(treeMaskMRT()))`,
|
|
38
|
-
* then read it with `scenePass.getTextureNode(TREE_MASK)`.
|
|
39
|
-
*/
|
|
40
|
-
function treeMaskMRT(selection = null) {
|
|
41
|
-
const node = mrt({ [TREE_MASK]: createTreeMask(selection) });
|
|
42
|
-
node.setClearColor(TREE_MASK, 0, 0);
|
|
43
|
-
return node;
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Creates `pass(scene, camera)` with MRT `{ output, treeMask }` and returns it with its colour and
|
|
47
|
-
* mask texture nodes. `selection`: the trees to outline (default `null` = all trees), see
|
|
48
|
-
* {@link createTreeMask}. If your pipeline already has a scene pass, merge {@link treeMaskMRT} into it instead.
|
|
49
|
-
*/
|
|
50
|
-
function treeEffectsPass(scene, camera, selection = null) {
|
|
51
|
-
const scenePass = pass(scene, camera);
|
|
52
|
-
scenePass.setMRT(mrt({ output }).merge(treeMaskMRT(selection)));
|
|
53
|
-
scenePass.getTexture(TREE_MASK).type = UnsignedByteType;
|
|
54
|
-
return {
|
|
55
|
-
pass: scenePass,
|
|
56
|
-
color: scenePass.getTextureNode("output"),
|
|
57
|
-
mask: scenePass.getTextureNode(TREE_MASK)
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
// src/effects/outline.ts
|
|
61
|
-
var D = Math.SQRT1_2;
|
|
62
|
-
var DIRECTIONS = [
|
|
63
|
-
[1, 0],
|
|
64
|
-
[-1, 0],
|
|
65
|
-
[0, 1],
|
|
66
|
-
[0, -1],
|
|
67
|
-
[D, D],
|
|
68
|
-
[D, -D],
|
|
69
|
-
[-D, D],
|
|
70
|
-
[-D, -D]
|
|
71
|
-
];
|
|
72
|
-
/**
|
|
73
|
-
* Tree Effect: an outline along the silhouettes of the selected trees (the `selection` of the
|
|
74
|
-
* tree mask, see `createTreeMask`; all trees by default), around the outside of the canopy and
|
|
75
|
-
* the gaps in it. The line is drawn on the inside of the silhouette, so only tree pixels change.
|
|
76
|
-
*/
|
|
77
|
-
function treeOutline(input, options = {}) {
|
|
78
|
-
const { color: color$2 = "#1d2a14", thickness = 2, strength = 1 } = options;
|
|
79
|
-
const { mask } = input;
|
|
80
|
-
const step = vec2(thickness).div(vec2(textureSize(mask)));
|
|
81
|
-
const centre = uv();
|
|
82
|
-
let outside = float(0);
|
|
83
|
-
for (const [x, y] of DIRECTIONS) outside = outside.add(float(1).sub(mask.sample(centre.add(step.mul(vec2(x, y)))).b));
|
|
84
|
-
const edge = outside.mul(3 / DIRECTIONS.length).clamp(0, 1).mul(mask.sample(centre).b).mul(strength);
|
|
85
|
-
return vec4(mix(input.color.rgb, color(new Color(color$2)), edge), input.color.a);
|
|
86
|
-
}
|
|
87
|
-
// src/effects/glow.ts
|
|
88
|
-
/**
|
|
89
|
-
* Tree Effect: a soft glow of the leaves. The bright (sunlit) leaf pixels are blurred and added
|
|
90
|
-
* back onto the tree pixels (leaves and the wood between them), never onto the rest of the scene.
|
|
91
|
-
*/
|
|
92
|
-
function leafGlow(input, options = {}) {
|
|
93
|
-
const { color: color$1 = "#ffffff", intensity = .6, threshold = .15, radius = 6 } = options;
|
|
94
|
-
const bright = smoothstep(threshold, threshold * 2 + .05, luminance(input.color.rgb));
|
|
95
|
-
const leaves = vec4(input.color.rgb.mul(input.mask.g).mul(bright), 1);
|
|
96
|
-
const glow = gaussianBlur(leaves, null, radius, { resolutionScale: .5 }).rgb.mul(color(new Color(color$1))).mul(intensity).mul(input.mask.r);
|
|
97
|
-
return vec4(input.color.rgb.add(glow), input.color.a);
|
|
98
|
-
}
|
|
99
|
-
// src/effects/grade.ts
|
|
100
|
-
var MID_GREY = .18;
|
|
101
|
-
/**
|
|
102
|
-
* Tree Effect: colour grading (exposure, tint, saturation, contrast) of the tree pixels only.
|
|
103
|
-
* Returns the graded colour where the tree mask is set and `input.color` unchanged elsewhere.
|
|
104
|
-
*/
|
|
105
|
-
function treeColorGrade(input, options = {}) {
|
|
106
|
-
const { exposure = 1, saturation = 1, contrast = 1, tint = "#ffffff" } = options;
|
|
107
|
-
const tinted = input.color.rgb.mul(color(new Color(tint))).mul(exposure);
|
|
108
|
-
const contrasted = mix(vec3(luminance(tinted)), tinted, saturation).max(0).div(MID_GREY).pow(vec3(float(contrast))).mul(MID_GREY);
|
|
109
|
-
return select(input.mask.r.greaterThan(.5), vec4(contrasted, input.color.a), input.color);
|
|
110
|
-
}
|
|
111
|
-
// src/effects/suggested.ts
|
|
112
|
-
/** The suggested combination of Tree Effects for each built-in Style. */
|
|
113
|
-
var SUGGESTED_TREE_EFFECTS = {
|
|
114
|
-
"low-poly": {
|
|
115
|
-
grade: {
|
|
116
|
-
saturation: 1.15,
|
|
117
|
-
contrast: 1.1
|
|
118
|
-
},
|
|
119
|
-
outline: {
|
|
120
|
-
color: "#18230f",
|
|
121
|
-
thickness: 2,
|
|
122
|
-
strength: .9
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
stylized: {
|
|
126
|
-
grade: {
|
|
127
|
-
saturation: .95,
|
|
128
|
-
contrast: 1.08,
|
|
129
|
-
tint: "#fff1e0"
|
|
130
|
-
},
|
|
131
|
-
glow: {
|
|
132
|
-
color: "#fff6c8",
|
|
133
|
-
intensity: .45,
|
|
134
|
-
threshold: .3,
|
|
135
|
-
radius: 8
|
|
136
|
-
},
|
|
137
|
-
outline: {
|
|
138
|
-
color: "#2b3a1c",
|
|
139
|
-
thickness: 2,
|
|
140
|
-
strength: .6
|
|
141
|
-
}
|
|
142
|
-
},
|
|
143
|
-
realistic: {
|
|
144
|
-
grade: {
|
|
145
|
-
exposure: 1.05,
|
|
146
|
-
contrast: 1.08,
|
|
147
|
-
saturation: .95,
|
|
148
|
-
tint: "#fff5e6"
|
|
149
|
-
},
|
|
150
|
-
glow: {
|
|
151
|
-
color: "#e8ffc0",
|
|
152
|
-
intensity: .35,
|
|
153
|
-
threshold: .12,
|
|
154
|
-
radius: 4
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
};
|
|
158
|
-
// src/effects/effects.ts
|
|
159
|
-
/**
|
|
160
|
-
* Applies a combination of Tree Effects to `input` and returns the resulting colour node, for use in
|
|
161
|
-
* your own post-processing pipeline (`pipeline.outputNode = applyTreeEffects(...)`, or feed it into
|
|
162
|
-
* more effects). Order: colour grade, leaf glow, outline. Empty settings return `input.color`.
|
|
163
|
-
*/
|
|
164
|
-
function applyTreeEffects(input, settings) {
|
|
165
|
-
let color = input.color;
|
|
166
|
-
if (settings.grade) color = treeColorGrade({
|
|
167
|
-
color,
|
|
168
|
-
mask: input.mask
|
|
169
|
-
}, settings.grade);
|
|
170
|
-
if (settings.glow) color = leafGlow({
|
|
171
|
-
color,
|
|
172
|
-
mask: input.mask
|
|
173
|
-
}, settings.glow);
|
|
174
|
-
if (settings.outline) color = treeOutline({
|
|
175
|
-
color,
|
|
176
|
-
mask: input.mask
|
|
177
|
-
}, settings.outline);
|
|
178
|
-
return color;
|
|
179
|
-
}
|
|
180
|
-
function resolveEffects(choice) {
|
|
181
|
-
if (choice === null) return {};
|
|
182
|
-
if (typeof choice !== "string") return choice;
|
|
183
|
-
const settings = SUGGESTED_TREE_EFFECTS[choice];
|
|
184
|
-
if (!settings) throw new Error(`No suggested Tree Effects for Style "${choice}"`);
|
|
185
|
-
return settings;
|
|
186
|
-
}
|
|
187
|
-
/**
|
|
188
|
-
* A ready-made post-processing pipeline (`RenderPipeline`) with the Tree Effects: render with
|
|
189
|
-
* `effects.render()` instead of `renderer.render(scene, camera)`. Switch the combination with
|
|
190
|
-
* `effects.set('stylized')` (e.g. a preview). For your own pipeline, use {@link treeEffectsPass}
|
|
191
|
-
* and {@link applyTreeEffects} instead.
|
|
192
|
-
*/
|
|
193
|
-
var TreeEffects = class {
|
|
194
|
-
pipeline;
|
|
195
|
-
/** The scene pass (colour + tree mask). */
|
|
196
|
-
scenePass;
|
|
197
|
-
nodes = [];
|
|
198
|
-
current = {};
|
|
199
|
-
constructor(renderer, scene, camera, options = {}) {
|
|
200
|
-
this.pipeline = new RenderPipeline(renderer);
|
|
201
|
-
this.scenePass = treeEffectsPass(scene, camera, options.selection ?? null);
|
|
202
|
-
this.set(options.effects ?? null);
|
|
203
|
-
}
|
|
204
|
-
/** The active combination (`{}` = none). */
|
|
205
|
-
get settings() {
|
|
206
|
-
return this.current;
|
|
207
|
-
}
|
|
208
|
-
/** Switches to a Style's suggested combination, custom settings, or none (`null`). */
|
|
209
|
-
set(effects) {
|
|
210
|
-
this.current = resolveEffects(effects);
|
|
211
|
-
this.disposeNodes();
|
|
212
|
-
const output = applyTreeEffects(this.scenePass, this.current);
|
|
213
|
-
this.nodes = collectEffectNodes(output, this.scenePass.color);
|
|
214
|
-
this.pipeline.outputNode = output;
|
|
215
|
-
this.pipeline.needsUpdate = true;
|
|
216
|
-
}
|
|
217
|
-
/** Renders the scene with the effects (call instead of `renderer.render(scene, camera)`). */
|
|
218
|
-
render() {
|
|
219
|
-
this.pipeline.render();
|
|
220
|
-
}
|
|
221
|
-
dispose() {
|
|
222
|
-
this.disposeNodes();
|
|
223
|
-
this.scenePass.pass.dispose();
|
|
224
|
-
this.pipeline.dispose();
|
|
225
|
-
}
|
|
226
|
-
disposeNodes() {
|
|
227
|
-
for (const node of this.nodes) node.dispose();
|
|
228
|
-
this.nodes = [];
|
|
229
|
-
}
|
|
230
|
-
};
|
|
231
|
-
/** The render-target owning nodes (blur) in an effects graph, to dispose them on change. */
|
|
232
|
-
function collectEffectNodes(output, stop) {
|
|
233
|
-
const found = /* @__PURE__ */ new Set();
|
|
234
|
-
const visit = (node, seen) => {
|
|
235
|
-
if (seen.has(node) || node === stop) return;
|
|
236
|
-
seen.add(node);
|
|
237
|
-
if (node.isGaussianBlurNode) found.add(node);
|
|
238
|
-
for (const child of node.getChildren()) visit(child, seen);
|
|
239
|
-
};
|
|
240
|
-
visit(output, /* @__PURE__ */ new Set());
|
|
241
|
-
return [...found];
|
|
242
|
-
}
|
|
243
|
-
/** Shorthand for `new TreeEffects(renderer, scene, camera, options)`. */
|
|
244
|
-
function createTreeEffects(renderer, scene, camera, options) {
|
|
245
|
-
return new TreeEffects(renderer, scene, camera, options);
|
|
246
|
-
}
|
|
247
|
-
export { SUGGESTED_TREE_EFFECTS, TREE_MASK, TreeEffects, applyTreeEffects, createTreeEffects, createTreeMask, leafGlow, treeColorGrade, treeEffectsPass, treeMaskMRT, treeOutline, treePartOf };
|
|
248
|
-
|
|
249
|
-
//# sourceMappingURL=effects.js.map
|
|
1
|
+
import { f as createTreeMask, h as treePartOf, m as treeMaskMRT, u as TREE_MASK } from "./motion-Qd7xjeZM.js";
|
|
2
|
+
import { C as treeIdMRT, S as treeFromId, T as treeIdTexture, _ as TREE_NORMAL, b as TREE_ID, d as SUGGESTED_TREE_EFFECTS, f as treeHighlight, g as treeEffectsPass, h as treeOutline, m as leafGlow, n as applyTreeEffects, o as createTreeEffects, p as treeColorGrade, t as TreeEffects, v as innerLines, w as treeIdOf, x as readTreeId, y as treeNormalMRT } from "./effects-qHx_8Dlk.js";
|
|
3
|
+
export { SUGGESTED_TREE_EFFECTS, TREE_ID, TREE_MASK, TREE_NORMAL, TreeEffects, applyTreeEffects, createTreeEffects, createTreeMask, innerLines, leafGlow, readTreeId, treeColorGrade, treeEffectsPass, treeFromId, treeHighlight, treeIdMRT, treeIdOf, treeIdTexture, treeMaskMRT, treeNormalMRT, treeOutline, treePartOf };
|
package/dist/forest/Forest.d.ts
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
|
-
import { BufferGeometry,
|
|
1
|
+
import { BufferGeometry, InstancedMesh, type Camera, type Mesh, type MeshStandardNodeMaterial, type Renderer, type Scene } from 'three/webgpu';
|
|
2
2
|
import type { MaterialFeatures, TranslucencyDefinition, TreeDefinition } from '../definition';
|
|
3
3
|
import { type TreeData } from '../generator';
|
|
4
|
+
import { type MaterialFeatureNodes } from '../materials/material-features';
|
|
5
|
+
import { LiveShaderHooks, ShaderHookedGroup, type ShaderHookTarget, type TreeShaderHooks } from '../materials/shader-hooks';
|
|
4
6
|
import { type TextureOptions } from '../textures';
|
|
5
7
|
import { Wind, WindResponse, type WindSource } from '../wind';
|
|
8
|
+
import { VariantImpostor } from './impostor';
|
|
9
|
+
import { VariantLevels, type DetailLevelUniforms } from './levels';
|
|
10
|
+
import { type ForestLodOptions, type ForestLodSettings, type ForestLodUpdate } from './lod';
|
|
6
11
|
import { type ForestPlacement, type ForestTreeTraits } from './placement';
|
|
7
12
|
/** Options of {@link createForest}. */
|
|
8
13
|
export interface ForestOptions {
|
|
@@ -18,6 +23,15 @@ export interface ForestOptions {
|
|
|
18
23
|
wind?: Wind;
|
|
19
24
|
/** Where the Definition's textures load from (as `createTree(..., { textures })`). */
|
|
20
25
|
textures?: TextureOptions;
|
|
26
|
+
/**
|
|
27
|
+
* Detail Levels (ADR 0010): draw far trees Light and as Impostors, with a cross-fade. `true` derives
|
|
28
|
+
* the switch distances from the tallest Variant's trunk height. Missing or false: the forest draws
|
|
29
|
+
* every tree in full, exactly as without this option. WebGPU only: on WebGPURenderer's WebGL2
|
|
30
|
+
* fallback it is ignored (one console warning). Switching it on or off needs a new Forest.
|
|
31
|
+
*/
|
|
32
|
+
lod?: boolean | ForestLodOptions;
|
|
33
|
+
/** The Tree Shader Hook per tree part (see {@link Forest.shaderHooks}). Default: none. */
|
|
34
|
+
shaderHooks?: TreeShaderHooks;
|
|
21
35
|
}
|
|
22
36
|
/** What the GPU draws one tree with (after its offsets). */
|
|
23
37
|
export interface ForestInstanceState {
|
|
@@ -41,6 +55,8 @@ export declare class ForestTree implements ForestTreeTraits {
|
|
|
41
55
|
readonly windPhase: number;
|
|
42
56
|
/** @internal Slot in the Variant's instance buffers. */
|
|
43
57
|
slot: number;
|
|
58
|
+
/** @internal The Variant drawing this tree, null once it is removed. */
|
|
59
|
+
owner: ForestVariant | null;
|
|
44
60
|
private growthValue;
|
|
45
61
|
private seasonValue;
|
|
46
62
|
/** @internal Use {@link Forest.addTree}. */
|
|
@@ -62,6 +78,8 @@ export declare class ForestTree implements ForestTreeTraits {
|
|
|
62
78
|
*/
|
|
63
79
|
export declare class ForestVariant {
|
|
64
80
|
private readonly forest;
|
|
81
|
+
private readonly wind;
|
|
82
|
+
private readonly textures?;
|
|
65
83
|
readonly index: number;
|
|
66
84
|
readonly seed: number;
|
|
67
85
|
readonly data: TreeData;
|
|
@@ -80,7 +98,14 @@ export declare class ForestVariant {
|
|
|
80
98
|
private readonly woodSource;
|
|
81
99
|
private readonly leafSource;
|
|
82
100
|
private readonly fruitSource;
|
|
83
|
-
|
|
101
|
+
private readonly definition;
|
|
102
|
+
/** @internal The Detail Levels this Variant draws its trees with; null until they are drawn (lod set, on WebGPU). */
|
|
103
|
+
levels: VariantLevels | null;
|
|
104
|
+
/** Vertex data of the Light level (null until Detail Levels are drawn). */
|
|
105
|
+
private lightSources;
|
|
106
|
+
/** @internal The Impostor of this Variant (atlases and card material); null until Detail Levels are drawn. */
|
|
107
|
+
impostor: VariantImpostor | null;
|
|
108
|
+
constructor(forest: Forest, definition: TreeDefinition, index: number, seed: number, wind: WindSource, capacity: number, textures?: TextureOptions | undefined);
|
|
84
109
|
/** Instanced mesh of trunks and branches. Replaced (not resized) when the Variant outgrows its capacity. */
|
|
85
110
|
get wood(): InstancedMesh<BufferGeometry, MeshStandardNodeMaterial>;
|
|
86
111
|
/** Instanced mesh of the leaves. Replaced along with {@link wood}. */
|
|
@@ -90,6 +115,11 @@ export declare class ForestVariant {
|
|
|
90
115
|
/** The Variant's meshes: wood, leaves and (with Fruit) fruit. */
|
|
91
116
|
get meshes(): InstancedMesh<BufferGeometry, MeshStandardNodeMaterial>[];
|
|
92
117
|
get capacity(): number;
|
|
118
|
+
/**
|
|
119
|
+
* @internal What Tree Shader Hooks shade on this Variant: its bark, leaf and Fruit materials (which draw
|
|
120
|
+
* every Detail Level but Impostor), with each tree's own Season, Growth and position.
|
|
121
|
+
*/
|
|
122
|
+
hookTargets(): ShaderHookTarget[];
|
|
93
123
|
/** @internal */
|
|
94
124
|
add(tree: ForestTree): void;
|
|
95
125
|
/** @internal Swap-removes a tree: the last tree takes its slot. */
|
|
@@ -98,6 +128,12 @@ export declare class ForestVariant {
|
|
|
98
128
|
write(tree: ForestTree): void;
|
|
99
129
|
/** @internal */
|
|
100
130
|
state(tree: ForestTree): ForestInstanceState;
|
|
131
|
+
/**
|
|
132
|
+
* @internal Starts drawing this Variant's trees by Detail Level (ADR 0010): a Full and a Light mesh
|
|
133
|
+
* set, drawn indirectly from the level lists, with the Variant's own materials (which get the
|
|
134
|
+
* cross-fade dither). The instanced meshes stay, hidden, for raycasting and Tree IDs.
|
|
135
|
+
*/
|
|
136
|
+
enableDetailLevels(uniforms: DetailLevelUniforms, settings: Pick<ForestLodSettings, 'lightDefinition' | 'impostorAtlas'>, setupMesh: (mesh: Mesh) => void, features?: MaterialFeatureNodes | null): void;
|
|
101
137
|
/** @internal Frees the GPU resources. */
|
|
102
138
|
dispose(): void;
|
|
103
139
|
private setCount;
|
|
@@ -114,7 +150,7 @@ export declare class ForestVariant {
|
|
|
114
150
|
* hash of the forest seed and the tree's id (or position), never from its index, so adding or
|
|
115
151
|
* removing trees never changes the others. Growth and Season can be set per tree or for all.
|
|
116
152
|
*/
|
|
117
|
-
export declare class Forest extends
|
|
153
|
+
export declare class Forest extends ShaderHookedGroup {
|
|
118
154
|
readonly isForest = true;
|
|
119
155
|
readonly definition: TreeDefinition;
|
|
120
156
|
/** The forest seed. */
|
|
@@ -127,10 +163,50 @@ export declare class Forest extends Group {
|
|
|
127
163
|
private growthValue;
|
|
128
164
|
private seasonValue;
|
|
129
165
|
private readonly features;
|
|
166
|
+
protected readonly hooks: LiveShaderHooks;
|
|
167
|
+
/** The trunk height of the tallest Variant (the distances of `lod: true`). */
|
|
168
|
+
private readonly tallestTrunk;
|
|
169
|
+
/** The Detail Levels; null without lod. */
|
|
170
|
+
private readonly detailLevels;
|
|
171
|
+
/**
|
|
172
|
+
* Resolves once every Impostor is baked (far trees draw Light until then); at once without lod; and
|
|
173
|
+
* on dispose. The backend is only known on the first render (three hands the renderer to the
|
|
174
|
+
* Forest's meshes then, not before), so on WebGPURenderer's WebGL2 fallback, where lod is ignored,
|
|
175
|
+
* it resolves on that first render, not at once.
|
|
176
|
+
*/
|
|
177
|
+
readonly lodReady: Promise<void>;
|
|
130
178
|
constructor(definition: TreeDefinition, placements?: readonly ForestPlacement[], options?: ForestOptions);
|
|
179
|
+
/**
|
|
180
|
+
* The Detail Level settings (a copy), null without lod. Setting `light`, `impostor`, `fade` or
|
|
181
|
+
* `camera` (the others kept) only writes uniforms: no rebuild, no recompile. Throws a RangeError for
|
|
182
|
+
* invalid values (keeping the old ones), and on a forest without lod (switching it on needs a new Forest).
|
|
183
|
+
*/
|
|
184
|
+
get lod(): ForestLodSettings | null;
|
|
185
|
+
set lod(value: ForestLodUpdate);
|
|
186
|
+
/**
|
|
187
|
+
* @internal The settings `lod` gives this Forest, every default filled in (`lod: true`: the distances
|
|
188
|
+
* from its tallest Variant's trunk height), or null when it is missing or false. Throws a RangeError
|
|
189
|
+
* for invalid settings.
|
|
190
|
+
*/
|
|
191
|
+
resolveLod(lod: boolean | ForestLodOptions | undefined): ForestLodSettings | null;
|
|
192
|
+
/** @internal The live Detail Level settings as uniforms (null without lod), for the GPU level selection. */
|
|
193
|
+
get lodUniforms(): DetailLevelUniforms | null;
|
|
194
|
+
/** @internal Whether Detail Levels are drawn: lod is set and the first render was on WebGPU (not the WebGL2 fallback). */
|
|
195
|
+
get lodActive(): boolean;
|
|
196
|
+
/**
|
|
197
|
+
* @internal Called before each instanced mesh is drawn: on the first render of a lod Forest, finds the
|
|
198
|
+
* backend (see `ForestLod`). Does nothing without lod.
|
|
199
|
+
*/
|
|
200
|
+
detectLodBackend(renderer: Renderer, scene?: Scene | null, camera?: Camera | null): void;
|
|
201
|
+
/**
|
|
202
|
+
* @internal How many trees each Detail Level drew in the last frame (indexed by DetailLevel; a tree
|
|
203
|
+
* in a cross-fade counts at both levels). All zero until Detail Levels are drawn. Reads the GPU.
|
|
204
|
+
*/
|
|
205
|
+
detailLevelCounts(renderer: Renderer): Promise<number[]>;
|
|
131
206
|
/**
|
|
132
207
|
* The Wind every tree of this forest sways with. Assigning another Wind only rebinds uniforms:
|
|
133
|
-
* no rebuild, no recompile
|
|
208
|
+
* no rebuild, no recompile (except the one-time node-graph rebuild when the Forest first follows a
|
|
209
|
+
* Wind that has had a Wind Burst, see `Wind.burst`).
|
|
134
210
|
*/
|
|
135
211
|
get wind(): Wind;
|
|
136
212
|
set wind(value: Wind);
|
|
@@ -160,6 +236,8 @@ export declare class Forest extends Group {
|
|
|
160
236
|
/** Season of the whole forest: setting it sets every tree's Season (and that of trees planted later). */
|
|
161
237
|
get season(): number;
|
|
162
238
|
set season(value: number);
|
|
239
|
+
/** @internal Materials made later (the Impostor cards) that the hooks shade too. */
|
|
240
|
+
addShaderHookTargets(targets: readonly ShaderHookTarget[]): void;
|
|
163
241
|
/**
|
|
164
242
|
* Crown Normals amount (0..1), from the Definition's `materials.leaf.crownNormals`; null when it is off.
|
|
165
243
|
* Setting it (clamped to 0..1) only writes a uniform: no regeneration, no recompile. Throws on a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Forest.d.ts","sourceRoot":"","sources":["../../src/forest/Forest.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,
|
|
1
|
+
{"version":3,"file":"Forest.d.ts","sourceRoot":"","sources":["../../src/forest/Forest.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EAKd,aAAa,EAMb,KAAK,MAAM,EACX,KAAK,IAAI,EACT,KAAK,wBAAwB,EAE7B,KAAK,QAAQ,EACb,KAAK,KAAK,EACX,MAAM,cAAc,CAAC;AAEtB,OAAO,KAAK,EAAE,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