SgSky
Renders the sky background. Sets the atmospheric backdrop for the scene and can be customized to simulate day/night cycles or different environments.
Inherits from
Usage
To use this class, add the following require at the top of your script:
Reference
create
Create a new sky object in the scenegraph.
Parameters
selfoptions(table): A table of options to fill the parametersparent(SceneObject): The parent scene object to add this to
Returns
Promise: promise which will resolve to the created object
Example
-- Options can be omitted. This example shows the defaults,
-- only specify the ones you want different.
SgSky.create({
active = true,
name = "",
layers = {0},
tags = {},
size = 1000,
turbidity = 10,
rayleigh = 2,
mieCoefficient = 0.005,
mieDirectionalG = 0.8,
inclination = 0.49,
azimuth = 0.25,
cloudScale = 0.02,
cloudSpeed = 0.01,
cloudCoverage = 0.4,
cloudDensity = 0.4,
cloudElevation = 0.5,
showSunDisc = true
})
Properties
You can access these properties directly on the object or through :get("propertyName") or :set("propertyName", value) methods.
| Property | Type | Default | Description |
|---|---|---|---|
| active | Boolean | true | Whether the procedural sky contributes lighting and background to the scene. |
| layers | Layers | [0] | Render layers this sky object belongs to for visibility and masking. |
| tags | Tags | [] | Labels for finding and filtering this sky object from scripts. |
| size | Float | 1000 | Angular size of the sun disc in the sky shader. |
| turbidity | Float | 10 | Haziness of the atmosphere. Higher values produce more muted, polluted skies. |
| rayleigh | Float | 2 | Rayleigh scattering coefficient controlling blue sky hue and atmospheric thickness. |
| mieCoefficient | Float | 0.005 | Strength of Mie scattering responsible for halos and haze around the sun. |
| mieDirectionalG | Float | 0.8 | Directionality of Mie scattering (0 = uniform haze, 1 = strong forward scattering). |
| inclination | Float | 0.49 | Vertical angle of the sun above the horizon, in degrees. |
| azimuth | Float | 0.25 | Horizontal rotation of the sun direction around the up axis, in degrees. |
| cloudScale | Float | 0.02 | Spatial scale of cloud noise patterns. Larger values produce bigger cloud formations. |
| cloudSpeed | Float | 0.01 | Animation speed of cloud movement across the sky. |
| cloudCoverage | Float | 0.4 | Fraction of the sky covered by procedural clouds (0 = clear, 1 = overcast). |
| cloudDensity | Float | 0.4 | Optical density of clouds. Higher values block more sunlight. |
| cloudElevation | Float | 0.5 | Height of the cloud layer relative to the sky dome. |
| showSunDisc | Boolean | true | Renders a visible solar disc in the sky dome. |