Prefer Corn.create, which also validates/initialises the renderer and pre-builds chunks.
Camera the levels of detail follow. Can be swapped at any time.
Where corn has been flattened. Replaced (cleared) when the fields change.
ReadonlyobjectRoot of the canopy and all plant chunks. Added to scene for you when one is passed to Corn.create.
Terrain height at world (x, z); NaN where there is no terrain.
Resolved settings (defaults ← your input). Read-only: change them with Corn.set.
ReadonlystatsLive counters, refreshed on every Corn.update.
ReadonlyuniformsShader uniforms, for advanced tweaks.
Per-plant brightness variation, 0..1.
1 tints corn by level of detail.
Dry leaf, husk and stubble colour.
Where corn was flattened (see FlattenMap).
minX, minZ, sizeX, sizeZ of the flatten map in world space.
Growth stage: 0 seedling … ~0.65 full height … 0.8 mature … 1 dry.
1 = harvested: stubble only.
Mature stalk height in metres, tassel included.
0..1 random height spread per plant.
Global multiplier on interactor push (and flattening).
Number of active entries in interactors.
xyz = world position, w = radius (0 = unused slot).
Mature leaf colour.
The four LOD density fractions.
The four LOD distances (x, y, z, w = LOD 0..3); stalks end at w.
Field-scale brightness and dryness variation, 0..1.
Bare soil colour between young rows and under the canopy.
Resistance to wind and interaction (never below 0.05).
Stubble height in metres after harvest.
Sun colour × intensity.
Direction towards the sun.
Tassel colour.
Back-lit glow of the leaves.
Position LOD is measured from (the Corn camera), so shadow passes see the same plants.
Normalised XZ wind direction.
Gust noise frequency (1/metres).
Gust travel speed.
How far stalks bend in the wind.
Young leaf colour (seedlings).
Stands all flattened corn back up.
Fraction (0..1) of plants kept at a distance from the camera: the CPU mirror of the shader's LOD curve.
Removes the corn from the scene and frees its GPU resources.
Flattens corn in a disk of radius metres around (x, z), falling along (dirX, dirZ) (e.g. a vehicle's
heading; omit to fall outwards). Interactors do this every frame; call it for anything else that knocks
corn down. Flattened corn stays down until Corn.clearFlattened.
How flattened the corn at world (x, z) is: 0 standing … 1 flat.
Replaces all settings with input: anything not given falls back to the defaults.
Changes settings at runtime, merging into what was set before. Looks, growth, harvest, wind and interaction
apply instantly through uniforms; fields, spacing, seed and chunk size rebuild the plants. undefined values
are ignored; wind merges field by field. Corn.reset drops earlier overrides.
Swaps the terrain (mesh or height function) and rebuilds plants and canopy.
Optionalterrain: TerrainStreams plant chunks around the camera, flattens corn under interactors and refreshes the shader state.
Called automatically when a scene was given (and by the <Corn> component); otherwise call it once per frame.
Milliseconds allowed for chunk builds this frame. Defaults to settings.buildBudget.
StaticcreateCreates a corn field and builds the chunks in view so the first frame is complete.
Corn fields: a threejs-grass variant of tall stalks planted in straight rows inside field polygons, with the grass wind, and the grass Interactors pushing plants aside and flattening the ones they drive over (the flattened corn stays down; see Corn.flattened). Plants are built in chunks around the camera, thinned by four levels of detail, and a canopy surface stands in for the plants that thinning drops, so whole fields render from the air.
Example