Reference
Presets
Seven looks from grasspro.html, one file each in src/config/presets/. Hover a card to see the wind move the field, click to enlarge it, or run one live.
meadowMid-morning spring grass, light fog, a scatter of flowers.goldenLow sun at 17:36 behind the blades, stronger translucency.windyTall grass on steep hills, strong gusts and gust sheen.wildflowersShort lush grass with the flower layer at full amount.autumnRusset grass, orange leaves and falling-leaf drift.savannaSparse, clumped dry grass, warm haze and flat acacias.night22:30 under the moon, with fireflies over the field.#Loading presets
grass.loadPreset('golden'); // by name
grass.loadPreset(JSON.parse(savedJson)); // or a preset object, e.g. copied from the demoloadPreset() applies the grass and wind sections at once. There is no easing. create({ preset }) does the same at start-up, and defaults to 'meadow'.
#Presets are plain data
/** @type {import('./index.js').GrassPreset} */
export default {
label: 'Golden Hour',
grass: { density: 1, height: 1.1, width: 1, season: 0.3, clumping: 0.5, translucency: 1.2, specular: 1, gustSheen: 1 },
wind: { speed: 0.35, gust: 0.5, direction: 200 },
scatter: { flowers: 0.2 },
environment: { time: 17.6, hills: 1, fog: 0.008, haze: 0, drift: 1, fireflies: false, savanna: false, camera: [-4.5, 1.8, -6.5] },
};| Section | Used by |
|---|---|
grass | GrassSystem: see Grass parameters |
wind | The grass's WindField |
scatter | A suggested flower amount. Your app applies it, for example with flowers.setAmount() |
environment | Staging hints for the demo: time of day, hill height, fog, haze, leaf drift, fireflies, savanna trees and the camera offset. The library ignores it |
getParams() keeps the scatter and environment sections of the last loaded preset, so a preset round-trips through loadPreset() and getParams() unchanged.
import { PRESETS, getPresetParams } from 'naturegl-grass';
Object.keys(PRESETS); // ['meadow', 'golden', 'windy', 'wildflowers', 'autumn', 'savanna', 'night']
getPresetParams('savanna'); // deep clone; throws on an unknown name#Try one live
windy. Press 1–7 in the demo to switch presets.#Reference
| Name | Label | Density | Height | Wind | Gust | Season | Demo staging |
|---|---|---|---|---|---|---|---|
meadow | Meadow | 1.0 | 1.0 | 0.55 | 0.6 | 0.12 | 10:30, light fog, some flowers |
golden | Golden Hour | 1.0 | 1.1 | 0.35 | 0.5 | 0.30 | 17:36, back-lit, translucency 1.2 |
windy | Windy Hills | 1.0 | 1.4 | 1.6 | 1.2 | 0.08 | 14:00, hills × 2.1, gust sheen 1.4 |
wildflowers | Wildflowers | 0.9 | 0.85 | 0.45 | 0.5 | 0.02 | 11:30, flowers amount 1.0 |
autumn | Autumn | 0.95 | 0.9 | 0.75 | 0.8 | 0.60 | 15:30, falling leaves |
savanna | Dry Savanna | 0.72 | 1.35 | 0.6 | 0.6 | 1.00 | 16:24, clumping 0.85, warm haze, flat acacias |
night | Night Fireflies | 1.0 | 1.0 | 0.3 | 0.35 | 0.18 | 22:30, fireflies |