How it's built
sync-libs and lib/
The game uses the four libraries exactly the way a customer uses the NatureGL downloads with "Option 1, copy build/". Each library's prebuilt bundle is vendored into lib/, and Vite aliases the package names to those files.
#What's in lib/
├── naturegl-sky/copy of ../naturegl-sky/build/├── naturegl-water/copy of ../naturegl-water/build/├── naturegl-grass/copy of ../naturegl-grass/build/├── naturegl-weather/copy of ../naturegl-weather/build/└── VERSIONS.jsonversion + sync time of each copy
Nothing in lib/ is edited by hand. The current copies are the 1.1.0 builds of all four libraries, synced on 2026-09-24.
#The aliases
const lib = name => resolve(root, `lib/${name}/index.js`);
export default defineConfig({
base: './',
resolve: {
alias: {
'naturegl-sky': lib('naturegl-sky'),
'naturegl-water': lib('naturegl-water'),
'naturegl-grass': lib('naturegl-grass'),
'naturegl-weather': lib('naturegl-weather'),
'naturegl-island': resolve(root, 'src/index.js'),
},
// one three.js instance shared by the game and every vendored library
dedupe: ['three'],
},
});The game's source imports the libraries by name (import { SkySystem } from 'naturegl-sky'), so switching to the npm packages later is a matter of deleting the aliases. dedupe: ['three'] matters: the bundles import three as a peer, and two copies of three.js in one page break instanceof checks and shader chunks.
#Refreshing the copies
The sibling packages have to be next to this one (../naturegl-sky and so on).
npm run sync-libs # copy ../naturegl-{sky,water,grass,weather}/build → lib/
npm run sync-libs:rebuild # run `npm run build:lib` in each package first
node scripts/sync-libs.mjs water sky # only some packagesFor each package the script removes lib/naturegl-<x>/, copies build/ into it, and records the package version and the time in lib/VERSIONS.json:
{
"naturegl-sky": { "version": "1.1.0", "syncedAt": "2026-09-24T06:55:58.995Z" },
"naturegl-water": { "version": "1.1.0", "syncedAt": "2026-09-24T06:55:59.137Z" },
"naturegl-grass": { "version": "1.1.0", "syncedAt": "2026-09-24T06:55:59.236Z" },
"naturegl-weather": { "version": "1.1.0", "syncedAt": "2026-09-24T06:55:59.334Z" }
}It exits with an error if a package folder is missing or has no build/index.js.