import { CompositeLayer } from '@deck.gl/core'; import type { Color, DefaultProps, LayerProps, Position } from '@deck.gl/core'; import { createPineCanopyMesh } from "./tree-geometry.js"; /** Tree species / silhouette variant. */ export type TreeType = 'pine' | 'oak' | 'palm' | 'birch' | 'cherry'; /** Season that drives default canopy colour when no explicit colour is supplied. */ export type Season = 'spring' | 'summer' | 'autumn' | 'winter'; /** * Crop configuration for a single tree. * * Pass this from `getCrop` to render small spherical crop points on the tree * and/or scattered on the ground around it. Works for fruit, nuts, or flowers * (flowering stage is expressed simply as a flower-coloured crop config). * * Positions are randomised deterministically from the tree's geographic * coordinates, so they are stable across re-renders. */ export type CropConfig = { /** Colour of each crop sphere [r, g, b, a]. */ color: Color; /** Number of crop spheres placed in the outer canopy volume (live/in-tree crops). */ count: number; /** * Number of crop spheres scattered on the ground within the canopy footprint * (dropped/fallen crops). * @default 0 */ droppedCount?: number; /** Radius of each individual crop sphere in metres. */ radius: number; }; /** Internal flat record for a single rendered crop sphere. */ type CropPoint = { position: [number, number, number]; color: Color; scale: number; }; type _TreeLayerProps = { /** Source data. */ data: DataT[]; /** Longitude/latitude position of the tree base. */ getPosition?: (d: DataT) => Position; /** Base elevation (metres above sea level). @default 0 */ getElevation?: (d: DataT) => number; /** * Silhouette / species variant. * 'pine' – layered conical tiers (evergreen) * 'oak' – wide spherical canopy * 'palm' – ring-scarred palm trunk with arching pinnate fronds * 'birch' – narrow oval canopy, pale bark * 'cherry' – round lush canopy, seasonal blossom * @default 'pine' */ getTreeType?: (d: DataT) => TreeType; /** * Total tree height in metres. * @default 10 */ getHeight?: (d: DataT) => number; /** * Fraction of total height occupied by the trunk (0–1). * @default 0.35 */ getTrunkHeightFraction?: (d: DataT) => number; /** * Trunk base radius in metres. * @default 0.5 */ getTrunkRadius?: (d: DataT) => number; /** * Horizontal radius of the canopy in metres. * @default 3 */ getCanopyRadius?: (d: DataT) => number; /** * Explicit trunk colour [r, g, b, a]. * When null the species default is used. * @default null */ getTrunkColor?: (d: DataT) => Color | null; /** * Explicit canopy colour [r, g, b, a]. * When null the species × season default is used. * @default null */ getCanopyColor?: (d: DataT) => Color | null; /** * Season used to pick the default canopy colour when no explicit colour is provided. * @default 'summer' */ getSeason?: (d: DataT) => Season; /** * Number of cone tiers for pine trees (1–5). * Higher values produce a denser layered silhouette. * @default 3 */ getBranchLevels?: (d: DataT) => number; /** * Optional crop configuration for this tree. * * Return a `CropConfig` to render small spherical crop points in the outer * canopy volume (live crops) and/or scattered on the ground around the trunk * (dropped crops). Return `null` to show no crops for this tree. * * The same accessor can express fruit, nuts, or flowering stage — pass * flower-coloured points (e.g. `[255, 200, 220, 255]`) for a blossom effect. * * Crop positions are randomised deterministically from the tree's geographic * coordinates; they are stable across re-renders. * * @default null (no crops) */ getCrop?: (d: DataT) => CropConfig | null; /** * Global size multiplier applied to all dimensions. * @default 1 */ sizeScale?: number; }; export type TreeLayerProps = _TreeLayerProps & LayerProps; type TreeLayerState = { grouped: Record; pineMeshes: Record>; liveCropPoints: CropPoint[]; droppedCropPoints: CropPoint[]; }; /** * **TreeLayer** — A parametric, Three.js-powered deck.gl layer that renders * richly configurable 3D trees at geographic positions. * * Each tree is composed of two `SimpleMeshLayer` instances: one for the trunk * (a tapered cylinder) and one for the canopy (silhouette depends on `getTreeType`). * All geometry is generated procedurally using Three.js `BufferGeometry` primitives * and converted to the `@loaders.gl/schema` `MeshGeometry` format accepted by * `SimpleMeshLayer`. * * Parametric controls include: * - Species / silhouette (`getTreeType`) * - Total height (`getHeight`) and trunk-to-canopy proportion (`getTrunkHeightFraction`) * - Trunk and canopy radii (`getTrunkRadius`, `getCanopyRadius`) * - Explicit or season-driven colours (`getTrunkColor`, `getCanopyColor`, `getSeason`) * - Pine tier density (`getBranchLevels`) * - Crop / fruit / flower visualisation (`getCrop`) * - Global scale factor (`sizeScale`) */ export declare class TreeLayer extends CompositeLayer>> { static layerName: string; static defaultProps: DefaultProps>; state: TreeLayerState; initializeState(): void; updateState({ props, oldProps, changeFlags }: { props: any; oldProps: any; changeFlags: any; }): void; /** * Build a single canopy sub-layer. * * Takes explicit `mesh`, `data`, and `layerId` so that pine trees can be * split into one sub-layer per level count (each with its own mesh). */ private _buildCanopyLayer; renderLayers(): any[]; } export {}; //# sourceMappingURL=tree-layer.d.ts.map