Environment
Contains functions to customize and control the world environment.
Functions
setSkyColor(color)
Sets skybox main color.
Parameters
- color — Color. Alpha will be ignored.
Example
Set sky color to red.
function onStart()
local red = Color.new(255,0,0)
Environment.setSkyColor(red)
end
Result
setEquatorColor(color)
Sets skybox equator color.
Parameters
- color — Color. Alpha will be ignored.
Example
Set equator color to green.
function onStart()
local green = Color.new(0,255,0)
Environment.setEquatorColor(green)
end
Result
setGroundColor(color)
Sets skybox ground color.
Parameters
- color — Color. Alpha will be ignored.
Example
Set ground color to yellow.
function onStart()
local yellow = Color.new(255,255,0)
Environment.setGroundColor(yellow)
end
Result
setSunColor(color)
Sets sun color. This also sets color of the light.
Parameters
- color — Color. Alpha will be ignored.
Example
Set Sun color to purple.
function onStart()
local purple = Color.new(128,0,128)
Environment.setSunColor(purple)
end
Result
setFogNearColor(color)
Sets fog starting color.
Parameters
- color — Color. Alpha controls fog density.
Example
Set fog near color to orange.
function onStart()
local orange = Color.new(255,165,0)
Environment.setFogNearColor(orange)
end
setFogFarColor(color)
Sets fog end color.
Parameters
- color — Color. Alpha controls fog density.
Example
Set fog far color to gray.
function onStart()
local gray = Color.new(128,128,128)
Environment.setFogFarColor(gray)
end
setBackgroundPrimaryColor(color, intensity)
Sets current background primary color.
Parameters
- color — Color. Alpha will be ignored.
- intensity — HDR intensity of the color.
- Min: -15
- Max: 15
Example
Set background primary color to pink.
function onStart()
local pink = Color.new(255,192,203)
Environment.setBackgroundPrimaryColor(pink,1)
end
Result
setBackgroundSecondaryColor(color, intensity)
Sets current background secondary color.
Parameters
- color — Color. Alpha will be ignored.
- intensity — HDR intensity of the color.
- Min: -15
- Max: 15
Example
Set background secondary color to brown.
function onStart()
local brown = Color.new(165,42,42)
Environment.setBackgroundSecondaryColor(brown,1)
end
Result
setEquatorHeight(height)
Sets equator height. Represents the height of the gradient between skyColor and equatorColor.
Parameters
- height — Value in range [0, 1].
- Min: 0
- Max: 1
Example
Set equator gradient heigth halfway between skyColor and equatorColor.
function onStart()
Environment.setEquatorHeight(0.5)
end
Result
setSkyboxOffset(offset)
Sets skybox offset. Represents the equator point. Default is 0.
Parameters
- offset — Value in range [-1, 1].
- Min: -1
- Max: 1
Example
Set skybox offset to 1. This will hide the Sun (night).
function onStart()
Environment.setSkyboxOffset(1)
end
Result
setFogStart(fogStart)
Sets start distance of the fog.
Parameters
- fogStart — Any positive number.
Example
Set the start distance of the fog to 5.
function onStart()
Environment.setFogStart(5)
Environment.setFogEnd(10)
end
Result
setFogEnd(fogEnd)
Sets end distance of the fog.
Parameters
- fogEnd — Any positive number. Can't be lower than start distance.
Example
Set the end distance of the fog to 5 (fog start has to be less than 5).
function onStart()
Environment.setFogStart(1)
Environment.setFogEnd(5)
end
Result
setFogIntensity(fogIntensity)
Sets fill (density) of the fog.
Parameters
- fogIntensity — Value in range [0, 1].
- Min: 0
- Max: 1
Example
Set the fog intensity to its maximum value.
function onStart()
Environment.setFogIntensity(1)
end
Result
setStarsIntensity(intensity)
Sets intensity of the stars. 0 will hide the stars completely.
Parameters
- intensity — Value in range [0, 5].
- Min: 0
- Max: 5
Example
Set stars intensity to 3.
function onStart()
Environment.setStarsIntensity(3)
end
Result
setSunIntensity(intensity)
Sets intensity of the sun. This controls the brightness of the sun visual and the light intensity.
Parameters
- intensity — Value in range [0, 5].
- Min: 0
- Max: 5
Example
Set Sun intensity to 0. This will make everything spooky and dark.
function onStart()
Environment.setSunIntensity(0)
end
Result
setCloudsIntensity(intensity)
Sets intensity (transperency) of the clouds. 0 will hide clouds completely.
Parameters
- intensity — Value in range [0, 1].
- Min: 0
- Max: 1
Example
Set clouds intensity to 0. This will hide the clouds.
function onStart()
Environment.setCloudsIntensity(0)
end
setCloudsSpeed(speed)
Sets the speed of the clouds.
Parameters
- speed — Number for cloud speed.
Example
Set clouds speed to 10.
function onStart()
Environment.setCloudsSpeed(10)
end
setAmbientIntensity(intensity)
Sets intensity of ambient light. This light is additional to the sunlight and lights object from all directions.
Parameters
- intensity — Value in range [0, 1].
- Min: 0
- Max: 1
Example
Set intensity of ambient light to 1. This will make everything visible even if there is no sun light.
function onStart()
Environment.setAmbientIntensity(1)
end
Result
setSunAngle(angle)
Sets the angle of the sun.
Parameters
- angle — Value in range [0, 360]. For daytime 0 - 180 for nighttime 181 - 360.
- Min: 0
- Max: 360
Example
Set the sun angle to 70 degrees.
function onStart()
Environment.setSunAngle(70)
end
Result
setBottomStars(enabled)
Enables or disables stars on the bottom part of the skybox.
Parameters
- enabled — True or false to toggle bottom stars.
Example
Disable stars on the bottom part of the skybox.
function onStart()
Environment.setBottomStars(false)
end
Result
set(properties)
Sets environment parameters in bulk.
Parameters
- properties — EnvironmentConfig with parameters to override.
Example
Set the sky completly red with a sun intensity of 3.
function onStart()
local red = Color.new(255,0,0)
local redSKy = {
skyColor = red,
equatorColor = red,
groundColor = red,
sunColor = red,
sunIntensity = 3
}
Environment.set(redSky)
end
Result
transition(properties, time)
Sets environment parameters in bulk over time.
Parameters
- properties — EnvironmentConfig with parameters to override.
- time — Time in seconds.
Example
Set a smooth 3 seconds transition between a red sky and a purple sky.
function onStart()
local red = Color.new(255,0,0)
local purple = Color.new(128,0,128)
local redSKy = {
skyColor = red,
equatorColor = red,
groundColor = red,
sunColor = red,
sunIntensity = 3
}
local purpleSky = {
skyColor = purple,
equatorColor = purple,
groundColor = purple,
sunColor = purple,
sunIntensity = 1
}
Environment.set(redSky)
Environment.transition(purpleSky, 3)
end