Reference
Grass parameters
Every look control the grass has. They live in two sections, grass and wind, and you change them with setParams(). Fields you leave out keep their value.
grass.setParams({
grass: { density: 0.9, height: 1.2, season: 0.35 },
wind: { speed: 0.8, direction: 120 },
});
grass.params; // the current grass section (read-only: use setParams)
grass.getParams(); // both sections, plus scatter / environment from the last presetChanges apply on the next frame. None of them re-bakes or rebuilds anything.
#grass
| Field | Default | Range | Effect |
|---|---|---|---|
density | 1 | 0..1 | Blade coverage. It also thins the turf colour on the ground |
height | 1 | 0.3..2 | Height multiplier. At 1 the blades are about 0.3–1.0 m |
width | 1 | 0.5..2 | Width multiplier on each ring's blade width |
season | 0.12 | 0..1 | Colour palette: 0 lush spring, 0.35 summer, 0.7 autumn, 1 dry savanna |
clumping | 0.55 | 0..1 | Tufts that share height and tint, with blades splaying outward |
translucency | 1 | 0..2 | Glow when back-lit |
specular | 1 | 0..2 | Anisotropic sheen along the blade |
gustSheen | 1 | 0..2 | How strongly gust fronts brighten the field |
The defaults are what setParams() fills in for a field that was never set. create() loads meadow unless you pass another preset.
#wind
| Field | new WindField() default | Range | Effect |
|---|---|---|---|
speed | 0.5 | 0..2 | Wind strength, and the speed of the gust fronts |
gust | 0.6 | 0..1.5 | Strength of the gust fronts on top of the steady wind |
direction | 40 | degrees | Where the wind blows towards. 0 = +X, 90 = +Z |
See Wind field for what they do to the blades and to patched materials.
#Seasons
season interpolates between four palette keys. grass.colors holds the current result as linear THREE.Colors: base, tip, dry and leaf. leaf suits trees and bushes, and the demo copies it onto its tree leaves.
season | Key | Base → tip |
|---|---|---|
| 0 | Lush spring | deep green → bright green |
| 0.35 | Summer | green → yellow-green |
| 0.7 | Autumn | brown → russet, with orange leaves |
| 1 | Dry savanna | brown → straw |
import { SEASONS, seasonColors } from 'naturegl-grass';
const { base, tip, dry, leaf } = seasonColors(0.5); // between summer and autumn
treeLeaves.color.copy(grass.colors.leaf);wildflowers: season 0.02meadow: 0.12autumn: 0.60savanna: 1.00#Demo sliders
The demo's sliders map onto these fields with these ranges:
| Slider | Field | Range |
|---|---|---|
| Density | grass.density | 0.1..1 |
| Height | grass.height | 0.3..2 |
| Wind | wind.speed | 0..2 |
| Gusts | wind.gust | 0..1.5 |
| Wind dir | wind.direction | 0..360° |
| Season | grass.season | 0..1 |
| Clumping | grass.clumping | 0..1 |
| Glow | grass.translucency | 0..2 |
| Sheen | grass.specular | 0..2 |
Time is demo-only. It moves the demo's sun and sky, and the grass follows through bindLights().