b3d-fog
Adds fog to a scene, useful for atmosphere and hiding distant tile pop-in.
When syncSkybox is true, the fog color automatically tracks the sibling
b3dSkybox's horizon color, so fog matches the sky at any time of day.
Attributes
| Attribute | Default | Description |
|---|---|---|
mode |
'linear' |
'linear', 'exp', or 'exp2' |
color |
'#bfd9f2' |
Fog color (hex, ignored when syncSkybox is true) |
start |
60 |
Start distance (linear mode) |
end |
120 |
End distance (linear mode) |
density |
0.01 |
Density (exp/exp2 modes) |
syncSkybox |
false |
Automatically match fog color to skybox horizon |
Usage
import { b3d, b3dFog, b3dSkybox, b3dSun } from 'tosijs-3d'
document.body.append(
b3d({},
b3dSun(),
b3dSkybox({ timeOfDay: 10, realtimeScale: 100 }),
b3dFog({ syncSkybox: true, start: 50, end: 100 }),
)
)