Skip to content

About

jardinero.dev with its hero photograph replaced by a live Three.js jardin a la francaise

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jardinero.dev — clone with a live hero

A static, self-contained copy of https://jardinero.dev with one change: the hero's still photograph has been replaced by a live 3D garden.

Run it

python3 serve.py

Then open http://localhost:5184. Everything is local — no CDN, no build step, no network access needed after the first load. serve.py is a plain static server that sends Cache-Control: no-store, because a browser holding a stale ES module looks exactly like a change that didn't work.

What was cloned

index.html, css/, js/main.js, assets/ and robots.txt are byte-for-byte what https://jardinero.dev serves. The only edits to the original files are:

  • index.html — an import map, a <canvas class="hero__garden"> and a <div class="hero__scrim"> inside the hero, and one <script type="module">.
  • css/styles.css — a block styling those two elements (.hero__garden, .hero__scrim), the .hero__shot → .shot rework below, and a smaller gap between the chips and the Jobs section.

One layout change beyond the hero: the dashboard screenshot used to sit inside the hero, cropped against its bottom edge, where it covered most of the garden. It now stands below the hero at the head of the Factory Overview section — the copy that describes it — and is shown whole rather than trimmed.

The hero background

The animation is opencolin/jardin-a-la-francaise — a jardin à la française in Three.js where every one of its ~650 plants is an individually grown object, under a sun that rises and sets and a wind that swells and drops.

js/garden/{plants,butterflies,palette,util}.js are that project's files, unchanged. scenery.js is that project's file with the night rewritten (see below), and garden.js differs by one line, returning the parterre mesh so the vista can repeat it. fireflies.js and vista.js are new. Its src/main.js is an interactive demo — HUD, orbit controls, click-to-inspect — none of which belongs behind hero copy, so js/garden/hero.js replaces it with a background driver:

  • a fixed camera at the head of the walk, drifting ±4° off the axis so the formal symmetry survives, tilted down onto the parterre so the broderie and urns carry the middle of the frame and the cypress colonnades close both side margins;
  • the day and wind loops, running on their own (one full day ≈ 150s, of which night is 16% — long enough for the moon to cross, short enough that the hero is not dark for long);
  • no input handling at all — the canvas never takes the pointer;
  • rendering suspended whenever the hero scrolls off-screen.

The vista

vista.js stamps the formal plan out twice more down the axis so the garden runs to the horizon instead of stopping at the treeline, and drops a still basin into the lawn between each block.

The copies are baked, not cloned: cloning ~650 plant groups per repeat would multiply the draw calls with them. Instead each plant's geometry is transformed into world space and merged per material — which works only because the garden upstream shares five materials between all its plants and carries each individual's colour in vertex attributes. Two whole extra blocks cost about 85 draw calls, not 1100. The far woodland that fell inside a new block is hidden, so it stays the edge and the horizon rather than growing out of a parterre.

The repeated basins are still water rather than mirrors: the near one is a Reflector, which costs a full extra render of the scene every frame. A standard material at low roughness picks up the scene environment instead, which at that distance is indistinguishable and free.

Two trade-offs worth knowing: baked copies hold their rest pose, so the distant ranks do not sway; and the distant blocks neither cast nor receive shadows.

The night

scenery.js is the one upstream file that is modified. The sky shader gained a time uniform and a moonDir uniform:

  • Stars are brighter and denser, and each one scintillates on its own phase and rate, both derived from the cell hash so no two beat together. The sine is squared, which biases the cycle towards the dim end so a star dwells faint and flares briefly rather than pulsing evenly. The horizon fade was also pulled in: the old ramp reached 0.3 in d.y, which covered the entire band this camera can actually see.
  • Fireflies (fireflies.js) come up as the butterflies settle and are gone by morning. Unlike the plants and butterflies, which are each their own object, the swarm is a single THREE.Points — one draw call. They are motes of light, not creatures with anatomy, and both their wandering and their blinking are computed in the vertex shader, so 110 of them cost nothing per frame on the CPU.
  • A shooting star falls now and then. Time is cut into epochs; each either has one or does not, and where it starts, which way it falls and how far all come out of that epoch's hash.
  • The moon is a new opaque disc with limb darkening, faint mottling and a glow. It takes the sun's azimuth from the far side, so it rises as the sun sets and crosses the sky through the night on its own. Its arc is deliberately only 22% of the sun's: the camera looks slightly down and sees barely 20° of sky, so a moon on the true antisolar arc would spend the whole night above the top of the frame. The moonlight now follows the visible disc instead of sitting at a fixed position.

sky.setClock(t) drives the twinkle and the meteor; it defaults to 0, so the upstream demo would still work unchanged.

Two bugs found along the way, both worth knowing about if you touch this shader:

  • The dome's vertex shader took vDir from the dome's centre, but the camera stands tens of units off that centre. The offset varies across the sky, which shears the angular field — enough to stretch the moon's disc into a visible ellipse. It now uses the true ray from the camera. The sun never showed this because it is a soft pow() falloff with no hard edge.
  • The meteor's per-epoch draw used the existing sin()-based hash. That is fine for the star field, where inputs stay small, but the epoch counter pushes sin() into the thousands, where 32-bit precision on the GPU stops distributing — every epoch failed the same test and no meteor ever fell. The meteor now uses a trig-free hash.

js/vendor/ holds Three.js r169 plus the two addons the garden uses (BufferGeometryUtils, Reflector), so the import map resolves locally.

When it doesn't run

The original assets/bg-hero.webp stays in the markup as the poster, and it is simply what you see if the garden never paints: prefers-reduced-motion, no WebGL, a hero box narrower than 761px, a lost context, or any error during setup.

Two of those are decided once, because they cannot change: reduced motion and a missing WebGL context. Width is watched, not sampled. It is measured on the hero element via ResizeObserver rather than read from innerWidth, because a surface that has not been laid out yet reports 0 — which reads as "phone" to a max-width query and would opt the garden out permanently on a large display. The scene is built the first moment there is real room for it, and it falls back again if the window is dragged down to phone width.

Note that some embedded surfaces (in-app preview panes, some webviews) never lay the document out and never fire requestAnimationFrame, while still painting something to the screen. The garden cannot run there and the poster is what shows. Open the page in a normal browser window to see it. The scrim that keeps the white headline legible against a bright sky is drawn only while the garden is up, so the poster keeps the contrast it was cut with.

Poking at it

window.heroGarden exposes { scene, camera, renderer, sky, butterflies, BASE, step, start, stop }. Mutating BASE.pos / BASE.target reframes on the next frame; step(dt) advances one frame by hand.

About

jardinero.dev with its hero photograph replaced by a live Three.js jardin a la francaise

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages