skydome3dplugin
The sky: the day clock, the sun and moon, weather and wind, fog, rain, snow and lightning.
Putting it in a scene
List it before render3d, and after terrain3d if it uses terrain3d's land (see Mods). The scene's sim lists the skydome3d kind from #plugins/skydome3d/skydome3d.sim.ts, and the scene has one { "is": "skydome3d" } actor whose prefab holds the row fields below.
"plugins": ["loader", "scenemanager", "player", "terrain3d", "skydome3d", "render3d"],
"world": {
"seed": 1,
"loader": { "assets": { "weathers": { "type": "json", "url": "/games/mygame/assets/weathers.json", "preload": true } } },
"skydome3d": {
"day": 1200,
"weathers": "weathers",
"soak": 20, "dry": 120, "lay": 60, "melt": 300,
"gusts": [3, 7, 13],
"bolt": { "lasts": [0.1, 0.4], "out": [300, 3000] },
"look": {…},
"precip": {…},
"shadow": { "map": 2048, "half": 60, "near": 1, "far": 300, "bias": 0.0005, "normalBias": 0.02 }
}
},
"prefabs": {
"skydome3d": { "t": 600, "rate": 1, "doy": 172, "lat": 45, "phase": 0.5, "to": "clear", "from": {…}, "mix": {…}, "blend": 1, "fade": 0, "wet": 0, "pack": 0, "windDeg": 0, "flash": 0, "strike": [0, 0], "drift": [0, 0] }
}
The weathers file is a table of weathers by name:
{
"clear": { "cloud": 0.15, "cirrus": 0.3, "base": 1800, "top": 2600, "dense": 0.3, "rain": 0, "snow": 0, "fog": 0, "haze": 0.3, "wind": 4, "gust": 0.2, "thunder": 0, "dust": 0 },
"storm": { "cloud": 0.95, "cirrus": 0.2, "base": 900, "top": 3200, "dense": 0.9, "rain": 1, "snow": 0, "fog": 0.2, "haze": 0.8, "wind": 14, "gust": 0.8, "thunder": 4, "dust": 0 }
}
Weather
A weather is these 13 numbers, all required. The sky moves between weathers by blending every number.
| Number | Meaning |
|---|---|
cloud | Cover of the main cloud deck, 0 to 1. |
cirrus | Cover of the high, thin cloud, 0 to 1. |
base, top | The deck's lower and upper altitude, in metres. |
dense | How thick and dark the clouds are. Thicker clouds also dim the sky and the lights. |
rain | Amount of rain, 0 to 1. Rain wets the ground. |
snow | Amount of snow, 0 to 1. At 0.02 or more, snow settles on upward-facing surfaces. |
fog | Amount of mist near the ground, 0 to 1. |
haze | Haze in the distance, 0 or more. |
wind | Wind speed, in metres per second. |
gust | How much the wind gusts, 0 to 1. |
thunder | Lightning strikes per minute. A scene whose weathers thunder needs a world.seed. |
dust | Amount of blowing dust, 0 to 1. |
Properties
The row
Read from the skydome3d actor's prefab. These change as the game runs and go to every seat.
| Field | Meaning |
|---|---|
t, rate | The time of day in seconds into a day, and how fast it runs. The clock advances rate sky seconds per second and wraps at day. |
doy, lat | The day of the year, and the latitude in degrees, north positive. They set where the sun and moon travel. |
phase | The moon's phase, 0 new and 0.5 full. It advances through a month every 29.53 sky days. |
to | The name of the weather the sky is moving to. |
from, mix | Each a whole weather. from is the weather the sky left, and mix is the weather standing now. Sound, the HUD and the sea read mix. |
blend, fade | How far the sky is from from to to, 0 to 1, and the seconds the change takes. |
wet, pack | How wet the ground is and how much snow lies on it, both 0 to 1. They follow the weather with a delay. |
windDeg | The direction the wind blows toward, in degrees clockwise from north. 0 blows toward −z and 90 toward +x. It wanders as the wind gusts. |
drift | [x, z], the total distance the wind has blown, in metres. It positions the clouds and falling snow and rain, so every seat sees the same. |
flash, strike | Seconds left of the current lightning flash, 0 when none, and where it struck, [x, z] in metres from the viewer. |
World settings
Read from world.skydome3d. A child scene inherits them from the manager scene.
| Setting | Meaning |
|---|---|
.day | Seconds in a sky day. |
.weathers | The loader catalogue name of the weathers file, a json entry with preload. |
.soak, .dry | Seconds for the ground to get wet, and to dry. Longer is slower. |
.lay, .melt | Seconds for snow to build up, and to melt. Sunshine melts it faster. |
.gusts | [a, b, c]: three whole numbers of gust cycles per sky day. The wind returns to the same strength at midnight. |
.bolt | { lasts: [lo, hi], out: [lo, hi] }: the range of a flash's length in seconds, and of its distance in metres. |
.biomes | Optional. Biome name to { scale?, add? }, each a partial weather: in that biome (terrain3d's), every number n becomes n·scale + add. The sky drawn is the weather under the camera, sliding from one biome's to the next as the camera crosses. Sound, wind, wetness and lightning stay the scene's. |
.look, .precip, .shadow | How it draws, below. Page only. |
.mods | { land: "terrain3d" } (see Mods). |
.look
Colours are sRGB strings.
| Keys | Meaning |
|---|---|
dayZenith, dayHorizon, nightZenith, nightHorizon | The sky gradient overhead and at the horizon, by day and by night. |
setZenith, setHorizon | The colours the gradient is pushed toward at sunrise and sunset. |
sunHigh, sunLow, moon | The colour of sunlight when high and when low in the sky, and of moonlight. |
ground | The ground colour of the hemisphere light. |
exposure, nightOpen | skydome3d sets render3d's exposure every frame to exposure·(1 + nightOpen·night), where night runs from 0 to 1. A higher nightOpen brightens the night. Any exposure in render3d's settings is overwritten. |
sunIntensity, moonIntensity | The strength of sunlight added to a base of 0.5 at midday, and of moonlight at full moon. |
hemiDay, hemiNight | The strength of the sky-and-ground light by day and by night. |
cloudScale, cloudSharp | The size of the cloud pattern in noise cycles per metre, and how sharp its edges are. |
cloudDrift | The fraction of the wind drift that reshapes clouds, so they change as they travel. |
cloudShadow | How much the cloud deck dims direct light on the ground. |
cloudLit, cloudShade, lining | The deck's lit colour, shaded colour, and the bright edge where light shines through. |
cirrusAlpha | The opacity of the high cloud. |
godrays | The strength of light shafts through gaps in the clouds. |
stars, starSize | The strength of the stars, and a star's radius in cells of its grid. |
twinkle, twinkles, twinkleSpread | How deep the twinkle goes, the whole twinkles per day, and the largest whole-number multiple of that a star may be given. |
sunShrink | [lo, hi]: the sun's height over which its disc shrinks from 0.0115 to 0.0080 radians. |
sunEdge, moonEdge | Where a disc's edge starts to soften, as a fraction of its radius. |
moonSize | The moon's radius in radians. |
snowScale | The size of the pattern snow settles in, in cycles per metre. |
flash | How far a lightning flash brightens the sky and the key light. |
radius | The dome's radius in metres. The render3d camera's far must be larger, or the sky is cut off. |
overcast | How much cloudy weather darkens the sky and the lights. |
haze, mist | Fog density: haze scales distant haze, and mist scales the weather's fog. |
envSun, envMix, envIntensity | The sky is also the scene's reflection map. It is rebuilt when the sun has turned by more than envSun radians or the weather blend has moved by more than envMix. envIntensity is how strongly it lights things. |
.precip
Rain, snow and dust fall in a box of range metres each way round the camera.
| Keys | Meaning |
|---|---|
range | Half the width of the box, in metres. |
rain, snow, dust, splashes | The most of each drawn, scaled by the weather. |
edge, near | Metres over which a drop fades out at the box's edge, and fades in from the camera. |
rainFall, rainLen, rainWidth, rainOpacity | Rain's fall speed in metres per second, streak length and width in metres, and opacity. |
snowFall, snowSize, snowOpacity, snowSway | The same for snow, with a sway. |
dustFall, dustSize, dustOpacity, dustColour, dustSway | The same for dust, with a colour. |
swayPeriod | Seconds. Each sway is rounded to a whole number of cycles of this. |
splashSize, splashLife, splashOpacity, splashRing | A rain splash's final radius, its life in seconds, opacity, and ring thickness as a fraction of its radius. |
lift | Metres a splash floats above the ground. |
keyShare | How much of the key light lights falling rain, snow and dust, besides the hemisphere light. |
A sway is [metres, radians per second, spread]: how far a flake wanders across x and z, how fast, and how much the rate differs between flakes.
.shadow
The key light, the sun or moon, always casts shadows. It needs render3d's shadows on, and meshes that cast and receive.
| Key | Meaning |
|---|---|
map | Shadow map size in texels. |
half | Half the width of the shadowed box, in metres. The box follows the camera. |
near, far | The box's depth along the light, in metres. |
bias, normalBias | Offsets that stop surfaces shadowing themselves. |
Methods
Acts
Closed acts. A rule calls them with w.call.
weather( name, fade )
Changes the sky to the named weather over fade seconds. If a change is under way, the new one starts from where the sky is now. A fade of 0 takes effect on the next step.
time( hours )
Sets the time of day, from 0 to 24 hours.
rate( x )
Sets how fast the clock runs.
moon( phase )
Sets the moon's phase, wrapped into 0 to 1.
place( lat, doy )
Sets the latitude in degrees and the day of the year.
On the page
Through plugins.skydome3d, undefined until the sky has drawn its first frame.
light( ) : object
The sky's light, for anything lit apart from the scene, such as a cockpit in render3d's overlay, and for the sea. The same object every frame, updated in place.
| Field | Meaning |
|---|---|
sun, sunColor | The direction toward the sun, and its colour scaled by its share of the key light. Zero once the moon has the key. |
key, keyColor | The direction toward the body the key light shines from, sun or moon, and its colour times its intensity, including any lightning flash. |
zenith, horizon | The sky colours overhead and at the horizon, in linear colour. |
fog | The scene's fog. |
sky, ground | The hemisphere light's two colours, times its intensity. |
Mods
Name them in world.skydome3d.mods.
- terrain3d
land: rain splashes land on the ground, and withbiomesthe weather follows the biome under the camera. With noland, splashes are not drawn. List terrain3d before skydome3d.
Used by
- ocean3dTakes its light and wind from the sky.
- render3dEvery dressed material gets the sky's wetness, snow and cloud shadows.