@relu-interactives/spatial-ecs
@relu-interactives/spatial-ecs / index / FoliageSystem
Class: FoliageSystem ​
Defined in: terrain/FoliageSystem.ts:224
Grass, trees and rocks on terrains (GrassComponent, ScatterComponent). Both are built in chunks around the camera, nearest first and a few a frame, and dropped once far behind, so a huge terrain costs what's near.
- Grass: one instanced mesh per chunk; the share of its blades drawn falls off with distance, so it thins out instead of ending in a line.
- Scatter: per item and chunk, the model's meshes as instances up close, flat pictures of it (impostors) from its impostor distance, nothing past its cull distance. Impostors are pictured once per model with the game's renderer.
A default system, in the editor too. world.foliage is this system.
Implements ​
Constructors ​
Constructor ​
ts
new FoliageSystem(): FoliageSystem;Returns ​
FoliageSystem
Properties ​
| Property | Modifier | Type | Default value | Description | Defined in |
|---|---|---|---|---|---|
runsWhilePaused | readonly | true | true | Keep ticking while the world is paused. Leave it unset for anything that moves the game on: such a system stops at world.pause() and picks up where it was at world.resume(). | terrain/FoliageSystem.ts:225 |
holdWind | public | (() => boolean) | null | null | While this answers true the wind stops (grass holds its pose): the editor holds it unless its Play animations toggle is on. A paused game holds it too. | terrain/FoliageSystem.ts:234 |
Methods ​
update() ​
ts
update(world, deltaTime?): void;Defined in: terrain/FoliageSystem.ts:236
Parameters ​
| Parameter | Type | Default value |
|---|---|---|
world | World | undefined |
deltaTime | number | 0 |
Returns ​
void
Implementation of ​
getStats() ​
ts
getStats(): {
grassChunks: number;
blades: number;
scatterChunks: number;
instances: number;
impostorChunks: number;
impostorDraws: number;
};Defined in: terrain/FoliageSystem.ts:281
What's drawn, for stats.
Returns ​
ts
{
grassChunks: number;
blades: number;
scatterChunks: number;
instances: number;
impostorChunks: number;
impostorDraws: number;
}| Name | Type | Defined in |
|---|---|---|
grassChunks | number | terrain/FoliageSystem.ts:282 |
blades | number | terrain/FoliageSystem.ts:283 |
scatterChunks | number | terrain/FoliageSystem.ts:284 |
instances | number | terrain/FoliageSystem.ts:285 |
impostorChunks | number | terrain/FoliageSystem.ts:286 |
impostorDraws | number | terrain/FoliageSystem.ts:287 |
reset() ​
ts
reset(): void;Defined in: terrain/FoliageSystem.ts:884
Forget pictured impostors and loaded models (tests, a renderer change).
Returns ​
void

