clouds
valley/clouds.js: the hand-laid cumulus (mulberry32 layout), the billow numbers, and the cloud cube (a five-face RGBA16F atlas) drawn by cloudMarch a strip at a time: setLight, drawAll, update. See ../README.md.
clouds
valley/clouds.js: the hand-laid cumulus (mulberry32 layout), the billow numbers, and the cloud cube (a five-face RGBA16F atlas) drawn by cloudMarch a strip at a time: setLight, drawAll, update. See ../README.md.
Interface
What this asset declares: the schema it conforms to, what it exposes, and the rendered structured payload.
conforms to
zero/source-extract/v2paintedValley.sky.clouds — the clouds of Painted Valley (valley/clouds.js, blendi/painted-valley on Patch, MIT). The clouds: summer cumulus painted the way a background artist would, as a few big simple masses with bright tops, blue shadow sides and flat darker bases. Each cloud is a heap of spheres whose surface is pushed about by billowing noise; a ray marcher draws them into a cube map round the valley, one strip a frame, so they can cost what they like and the sky itself is a single lookup. Port: the layout and the billows' random numbers are the original's, drawn from the same mulberry32 streams in the same order. The billow volume is filled on the GPU (cloudBillow), the cube is marched by cloudMarch into a five-face RGBA16F atlas (see skyCommon.shaderModule). drawAll() repaints every face; where the original does that in one go, here it is laid out over a few frames (STRIPS_PER_FRAME strips a frame) so no one frame holds the GPU for long. update() is the original's: one strip of one face a frame while `live`.
mulberry(seed: number) → void
mulberry32, as clouds.js has it.
| arg | type | description |
|---|---|---|
| seed | number |
billowNumbers( ) → void
The random numbers billowTexture(64) draws from mulberry(90210), in its order: grid(3), grid(6), grid(12), grid(24) (three a cell), then lattice(4), lattice(8), lattice(16). One flat array (the GPU rounds each to f32, as the original's Float32Arrays did).
layout(hero: { number }) → void
The sky's clouds, laid out by hand round the way the valley runs: a tower over the mountains ahead, two more heaped clouds to either side of it, fair-weather cumulus scattered nearer, and a bank lying along the mountains' feet. Metres, with the start of the walk at the origin. Returns { { puffs = { {x, y, z, r} }, base, scale } }.
| arg | type | description |
|---|---|---|
| hero | { number } |
at(u: number, v: number) → void
| arg | type | description |
|---|---|---|
| u | number | |
| v | number |
heap(into: { any }, x: number, y: number, z: number, w: number, h: number, n: number) → void
A rounded mound of puffs, `w` across and `h` tall, its middle at (x, y, z): one head of a cloud.
| arg | type | description |
|---|---|---|
| into | { any } | |
| x | number | |
| y | number | |
| z | number | |
| w | number | |
| h | number | |
| n | number |
cumulus(u: number, v: number, base: number, width: number, height: number, puffs: number, heads: number?) → void
A cumulus: a flat-based cloud `width` across and `height` tall. `heads` more mounds are heaped on the first, each smaller and higher, leaning one way, as a real tower builds.
| arg | type | description |
|---|---|---|
| u | number | |
| v | number | |
| base | number | |
| width | number | |
| height | number | |
| puffs | number | |
| heads | number? |
pack(list: { any }) → void
The puffs, the clouds' bounding spheres and their info, packed as the original's uniforms are (the first MAX_PUFFS puffs; every unused slot zero). Also returns how many puffs the layout holds in all.
| arg | type | description |
|---|---|---|
| list | { any } |
setVec(u: { number }, at: number, v: { number }) → void
| arg | type | description |
|---|---|---|
| u | { number } | |
| at | number | |
| v | { number } |
create(hero: { number }, options: { size: number?, steps: number?, live: boolean? }?) → void
Make the clouds: options.size texels along a side of each face of the cube; options.steps the marcher's; options.live false to draw the clouds once and leave them. Returns the cloud set (see below).
| arg | type | description |
|---|---|---|
| hero | { number } | |
| options | { size: number?, steps: number?, live: boolean? }? |
billowOnce( ) → void
flush( ) → void
draw(unit: number) → void
| arg | type | description |
|---|---|---|
| unit | number |
setLight(l: { [string]: any }) → void
The light on them. Any of: sunDir, lit, mid, shade, under, haze (arrays {r, g, b} in linear light).
| arg | type | description |
|---|---|---|
| l | { [string]: any } |
drawAll(now: boolean?) → void
Every face: at the start, and whenever the light changes. (They hold their shape: redrawn a strip at a time, clouds that billowed moved in jumps; uTime stays 0.) Laid out over the next frames, STRIPS_PER_FRAME a frame; `now` draws them all at once.
| arg | type | description |
|---|---|---|
| now | boolean? |
pump(budget: number?) → number
Draws up to `budget` strips of what drawAll still owes. Returns how many are left.
| arg | type | description |
|---|---|---|
| budget | number? |
ready( ) → boolean
Whether drawAll has drawn every face.
update(dt: number) → void
One strip of one face a frame: the clouds billow slowly, and nobody pays for it. (And what drawAll still owes, a few strips a frame.)
| arg | type | description |
|---|---|---|
| dt | number |
free( ) → void
Frees the clouds' GPU resources.
Sub-parts
Everything contained inside this part. Assets are composite children (clickable cards). Files are leaf payloads. Expand any row to view its source.
Problems
Everything affecting this asset right now: its own problems, anything wrong inside it, and problems on its direct dependencies.
agent_score is exposed.+ quality × 0.35
+ performance × 0.25
± compat factor
Usability ratings
Did the part work as advertised when consumers tried to drop it in. Separate from upvotes: those are taste; this is "did it function".
Scoped to this part · feeds back into the world's score.