Interaction

Grassworks uses a camera-following interaction map to turn registered influence objects into local grass bending.

Register influence objects

js
grassworks.addInfluence(carTire);
grassworks.addInfluence(otherTire);

// Remove one later
grassworks.removeInfluence(carTire);

// Or clear them all
grassworks.clearInfluences();

The interaction model uses sphere approximations rather than evaluating the complete mesh geometry. Spheres are therefore recommended when you need predictable localized contact such as car tires or feet.

Interaction world size

interactionWorldSize controls how much world space the camera-following interaction map covers. A larger value covers more area but spreads the available map resolution across more space; a smaller value concentrates the map around a tighter region.

Interaction resolution

interactionResolution controls the map's resolution. Higher resolution provides finer interaction detail. If you increase the world size significantly, increasing resolution may be necessary to preserve local accuracy.

Recovery speed

influenceRecoverySpeed controls how quickly grass returns toward its upright state. Higher values recover faster; lower values leave effects more persistent.

Debug plane

Enable influenceDebugPlaneVisible to visualize the interaction map coverage. This is useful when tuning world size and resolution because you can see the region in which influence effects are being represented.