Forest Logo
search
package_2

solar-system

By @dooougs

Roblox

Mirrored from Wally

SolarSystem

A real sun, moon and planets over any place on Earth, worked out from a shared UTC clock, for Roblox. Every server and client computes the same sky with nothing sent over the network. Optional client driver moves Roblox's own sun to match and eases the lighting through night, dawn, day and dusk.

Extracted from Plant World.

Install

[dependencies]
SolarSystem = "dooougs/solar-system@0.1.0"

Use

local SolarSystem = require(ReplicatedStorage.Packages.SolarSystem)

local sky = SolarSystem.new({
    location = { lat = 55.95, lon = -3.19 }, -- or function() return lat, lon end
})

print(sky:phase(), sky:daylight(), sky:state().sunrise)
sky:onPhaseChanged(function(phase, state) print("now", phase) end)

-- client only
SolarSystem.Lighting.start(sky, { indoor = nil, updateEvery = 0.5 })

SolarSystem.new(options)

optiondefault
locationrequired{lat, lon} or function() -> lat, lon (lazy, may yield)
clockworkspace:GetServerTimeNowfunction() -> unix seconds
offsetAttribute"SolarHourOffset"attribute with a test hour offset; false turns it off
offsetHolderReplicatedStorageinstance holding that attribute
dayAbove / nightBelow6 / -6sun heights (degrees) bounding day and night
horizon-0.833sunrise/sunset height
watchInterval0.5seconds between phase checks
phaseEventstruefalse and onPhaseChanged never fires

SolarSystem.Lighting.start(sky, options) (client)

optiondefault
placeSuntruemove Roblox's sun (ClockTime + GeographicLatitude) to the real sun
blendLookstrueblend Brightness, ambient, colour shift by sun height
looksDEFAULT_LOOKS{ {at = degrees, look = {...}} }, last is the day
dayLookFromPlacetrueread the day look from the place's own Lighting
dayLookDelay0seconds to wait before reading it
atmosphere / colorCorrection / sunRaystruewhich effects to tint
updateEvery0.5seconds between updates
indoornilfunction() -> {inside, dark?, tint?, bright?} for indoor light
connectsignal:Connectfunction(signal, label, fn) to hook a frame budgeter

Pure maths

SolarSystem.Astro (subsolar point, moon, sunAt(lat, lon, t)), SolarSystem.Geo (lat/lon <-> globe vectors), SolarSystem.Planets.sky(t), SolarSystem.MoonMap (Moon brightness tiles).

Package Details

Install command (Click to copy)


Version

0.1.0

License

MIT

check_circle

Safe for commercial use

Automated license review — not legal advice.