Skip to content

Add rotation attribute to the ProceduralSky script - #9150

Merged
mvaligursky merged 1 commit into
mainfrom
mv-sky-rotation
Jul 31, 2026
Merged

Add rotation attribute to the ProceduralSky script#9150
mvaligursky merged 1 commit into
mainfrom
mv-sky-rotation

Conversation

@mvaligursky

Copy link
Copy Markdown
Contributor

The ProceduralSky script drives the sky from a sun azimuth and elevation, which a day / night cycle typically animates. There was no way to orient the resulting sky over a scene without reaching into that mapping - offsetting the azimuth a cycle is writing every frame means the cycle no longer means what it says.

This adds a single angle that turns the whole sky around Y instead. It is added to the sun azimuth internally, so the sky, the sun, the sun light and the shadows it casts all turn together, and the azimuth / elevation an application animates keep their meaning. The moon direction turns with it too, so the moon and the night key light hold their place relative to the sun's path.

The only part not turned by it is the procedural star field, which stays anchored to the world axes - not observable, as the stars are noise to begin with. The existing lighting re-bake triggers itself off the sun direction, so nothing extra is needed to keep the image based lighting in sync.

Changes:

  • New rotation attribute, in degrees, applied in _computeSunDir
  • New private _computeMoonDir, used by both the moon disc uniform and the night key light, so the moon turns with the sky

API Changes:

  • ProceduralSky#rotation - number, degrees, range 0-360, defaults to 0 (no rotation), so existing behaviour is unchanged

Examples:

  • graphics/procedural-sky - added a Rotation slider to the Sky panel

Turns the whole sky around Y by adding the angle to the sun azimuth, so the sky, the sun, the
moon, the sun light and its shadows all turn together, leaving the azimuth and elevation a day /
night cycle animates untouched.
@github-actions

Copy link
Copy Markdown

Build size report

This PR does not change the size of the minified bundles.

Bundle Minified Gzip Brotli
playcanvas.min.js 2357.3 KB — 605.1 KB — 469.8 KB —
playcanvas.min.mjs 2354.6 KB — 604.2 KB — 469.3 KB —

@mvaligursky
mvaligursky merged commit 2e1fe02 into main Jul 31, 2026
10 checks passed
@mvaligursky
mvaligursky deleted the mv-sky-rotation branch July 31, 2026 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant