The page only ever shows a still or a clip. Every clip starts on the still you leave and ends on the still you land on, with both ends pixel-locked in post, so the swap between image and video is invisible. Every Back button plays an exact reversed copy of the forward clip, so going back looks like rewinding. The floor you point at lights up from a floor map traced off the tower's balcony slabs.
You need the Higgsfield MCP. In Claude go to Customize, install the Higgsfield plugin and sign in (Claude Code with the Higgsfield MCP works too). The prompt has your AI generate the tower, the five room stills and the five transition clips on Higgsfield, then build the page and hand you a zip. Budget about 150 to 300 credits; it checks your balance first. Higgsfield's Black Friday deal: 70% off Pro plans.
The prompt
Paste this into Claude with the Higgsfield MCP connected. It works through every step without stopping.
# Choose Your Floor — interactive luxury tower tour (Higgsfield MCP · Full site)
You are going to build a complete, working real-estate website from scratch, generating every image and video yourself with the Higgsfield MCP. Do the whole job end to end in this conversation. Don't ask me questions unless a setting below tells you to stop.
**What the visitor gets:** a luxury tower at blue hour, full screen. They point at a floor and that floor's windows light up, with its number beside the tower. A frosted panel on the right shows the level and unit type. They press **Enter**. The camera flies across the marina, up the facade, over that floor's balcony and in through the open glass, and lands in the apartment's living room. Labels on the doors (Bedroom, Kitchen, Bathroom) walk them room to room, and the bedroom has a further door to an en-suite shower room. Every "Back" plays the same move in reverse. Nothing ever cuts, flashes or reloads.
**Why it is seamless:** the page only ever shows a STILL or a CLIP. Every clip's first frame is the still you are leaving and its last frame is the still you arrive at. Both ends are pixel-locked in post, so swapping image ↔ video is invisible. Every "Back" plays an exact reversed copy of the forward clip.
---
## SETTINGS (keep the defaults or change them before sending)
- **SETTING:** a calm turquoise lagoon marina at blue hour, white yachts, palm-lined quay, Gulf-coast luxury
- **TOWER:** a residential tower whose oval floor plates each rotate a few degrees, so the building spirals; every floor has a wraparound white balcony with a glass railing; a sculptural white podium with a cantilevered canopy at the base
- **APARTMENT:** a two-bedroom show residence in warm white oak, pale travertine and bronze, with amber cove lighting
- **REVIEW_STILLS:** off. If "on", stop after Step 2, show me the chosen stills and wait for my go-ahead before spending video credits.
- **BUDGET:** about 150–300 Higgsfield credits. Check `balance` first and stop if it is lower.
If SETTINGS were changed, rewrite only the setting, tower and material phrases inside the prompts below. Keep every composition, framing, camera, light and "no text" instruction word for word.
---
## HOW TO WORK (read before starting)
1. Keep a short task list and tick items off as you go.
2. **Generation:** use only the Higgsfield MCP. Use `generate_image` / `generate_image_batch` for stills and `generate_video_batch` for clips. Use `jobs_wait` to poll and `show_generation_by_ids` to show me results.
- **Stills:** always `gpt_image_2_6`, quality `high`, resolution `2k`, aspect_ratio `16:9`.
- **Clips:** always `kling4_0`, mode `image-to-video`, resolution `1080p`, aspect_ratio `16:9`.
- Do **not** use Seedance for these clips: in omni_reference mode it does not hold the start frame, which breaks the seamless swap.
- Pass references as job IDs in `medias` with the role stated in each step.
3. **All downloading, checking and processing happens inside the Higgsfield sandbox (`sandbox_exec`).** It has internet access, ffmpeg, ImageMagick, Python with Pillow and numpy, and Playwright with Chromium.
- Pull each result in with `curl` from its `result_url`. Your own environment may not be able to reach the Higgsfield CDN, so don't try.
- Work in `~/tour` with the subfolders `src/`, `qc/`, `site/assets/` and `pack/`.
- Commands time out at 120 s, so run anything longer with `background: true` and poll it.
4. **Never send files into the sandbox as base64 or as text chunks; it refuses them.** Write scripts and the HTML template as source code with quoted heredocs (`cat > file <<'EOF'`). Produce data (like the floor map) inside the sandbox.
5. **Look at your own outputs before choosing.** Make JPG contact sheets in the sandbox and view them with `sandbox_exec` `image_paths` (max 4 images, max 512 KB in total). Choose against the acceptance criteria. Never choose blind.
6. **No audio anywhere.** Kling returns an AAC track even though you never ask for one; the lock step strips it.
7. **Hosting a file:** call `media_upload` (up to 20 file names per call). Then, inside the sandbox and from the folder that holds the file, run the returned `curl -X PUT …` command exactly as given. Finally call `media_confirm` with type `image` / `video` / `file`.
- The public link is the returned `url` (`https://d2ol7oe51mr4n9.cloudfront.net/…`).
- If a PUT returns anything other than 200, retry it once.
- Don't host the .html itself this way: it gets served as plain text. Ship the page inside the zip.
8. Use the file names exactly as written; the page expects them.
---
## STEP 1 — The tower (`tower`)
Call `generate_image` with `count: 3` and this prompt:
> Photorealistic luxury real-estate marketing photograph, wide 16:9. A 30-storey residential tower whose oval floor plates each rotate a few degrees from the one below, so the whole building spirals dramatically as it rises; every floor has a wraparound glass-railed balcony with a white edge, glass curtain wall behind. A sculptural white podium with a cantilevered canopy, glowing warm, at the base. Foreground: a turquoise lagoon marina with a handful of white yachts, palm-lined quay, gentle reflections. Blue hour, clear deep-blue sky, several apartments lit warm amber. The ENTIRE tower is visible from crown to ground, standing slightly left of centre (about 40% from the left edge); the right third of the frame is open sky and water, kept clear. Every floor reads as a distinct horizontal band so individual levels can be counted. Camera across the water at low height, 35mm, crisp architectural-photography realism. No text, no logos, no watermark.
**Accept a variant only if all of these hold:**
- The whole tower is in frame, crown to ground.
- It stands 30–40% from the left edge.
- The right ~45% of the frame is clear sky, because the panel sits there.
- Every floor is a separate white balcony band.
- It is blue hour with warm windows.
Keep the best variant's job ID as **TOWER**. If none passes, generate 3 more.
## STEP 2 — The stills the clips start and end on
**2a. Living room, the hub (`living`).** Call `generate_image` with `count: 3` and `medias: [{role: "image_references", value: TOWER}]`:
> Photorealistic luxury interior architectural photograph, wide 16:9, of the living room of a two-bedroom apartment on a mid-level floor of the spiralling oval tower shown in the reference image (same architecture, same blue-hour evening, same sea). Camera stands on the curved outdoor balcony at the threshold of a wide floor-to-ceiling glass sliding door that is fully open, looking INTO the apartment at eye level, 24mm lens; the slim dark-bronze frame of the open glass door panel is visible at the right edge. Inside: an open-plan living room with pale travertine floor, warm white-oak wall panelling, a low white boucle sofa, a travertine block coffee table, a sculptural ceramic vase. Three clearly visible openings lead off the living room: on the LEFT an open doorway into the primary bedroom (corner of a made bed visible, soft warm light); in the CENTRE-BACK an open kitchen with a long oak island and integrated oak cabinetry with warm under-cabinet lighting and built-in ovens; on the RIGHT an open pivot door through which the primary bathroom is visible, with a freestanding pale stone bathtub against a warm travertine wall lit by a cove light. The apartment's outer wall is curved floor-to-ceiling glass (oval floor plate) showing the sea at blue hour in deep blue light. Warm recessed cove lighting inside contrasting with cool blue dusk outside. Calm, uncluttered, high-end, no people, no text, no watermark.
**Accept only if all of these hold.** This is the most important still, because every walk starts or ends here.
- The camera stands **on the curved balcony**, looking in through a fully open glass door.
- **Three openings are clearly visible:** the bedroom door on the left, the kitchen at the centre-back, and the bathroom door with a freestanding tub on the right.
- The curved glass on the left shows the sea at dusk.
Keep it as **LIVING**.
**2b–2e.** Submit one `generate_image_batch` with 2 variants of each of these 4 stills (8 jobs), then choose one of each:
- **`balcony`**, used only as the fly-in's middle keyframe. References: TOWER, then LIVING (both `image_references`).
> Photorealistic aerial drone photograph, wide 16:9, blue hour. Exterior close-up of the spiralling oval tower from reference image 1: the camera hovers in mid-air about eight metres outside a mid-level floor, level with it, looking straight at that floor's curved wraparound balcony. The balcony's smooth white rounded slab edge and frameless glass railing run across the frame in a gentle curve; the white curved slab edges of the floors directly above and below are visible at the top and bottom of the frame, each slightly rotated, showing the spiral. Behind the balcony, a wide floor-to-ceiling glass sliding door stands fully open and the warmly lit living room from reference image 2 is clearly visible inside, centred in frame: the curved white boucle sofa, travertine coffee table, oak-panelled walls, the oak kitchen island in the back, cove lighting glowing amber. Neighbouring apartments on the floors above and below are darker with some warm lights. Deep blue dusk sky reflected in the glass, a sliver of calm turquoise sea far below at the bottom-left. Crisp, architectural-photography realism, no people, no text.
Accept: the same living room is recognisable through the open doors, with curved white slabs above and below.
- **`kitchen`**. Reference: LIVING.
> Photorealistic luxury interior photograph, wide 16:9, eye level, 24mm. The open kitchen of the exact apartment in the reference image (same materials, same blue-hour evening, same warm cove lighting): the camera has walked forward from the living room and now stands just in front of the long white-oak kitchen island, looking straight at the kitchen wall. Pale travertine island top with an integrated sink and a bronze tap, three upholstered bar stools on the near side of the island, floor-to-ceiling white-oak integrated cabinetry, two built-in black ovens on the right, a travertine backsplash niche glowing with warm under-cabinet LED light, a bowl of lemons, a vase of olive branches. Recessed ceiling downlights and the curved cove light above. On the left edge, part of the curved floor-to-ceiling glass wall showing the deep-blue sea at dusk. Pale travertine floor. Calm, uncluttered, no people, no text.
Accept: a straight-on view, as if you walked forward from the hub, with the curved glass on the left.
- **`bedroom`**. Reference: LIVING.
> Photorealistic luxury interior photograph, wide 16:9, eye level, 24mm. Primary bedroom of the exact apartment in the reference image, same white oak, travertine and amber cove lighting, blue hour outside. View from just inside the doorway: a low king bed dressed in white linen facing a sweeping curved floor-to-ceiling window onto the sea in deep blue dusk light, oak bedside tables with warm lamps, a cream lounge chair by the window. On the right wall, an open tall oak door leads into an en-suite shower room with travertine walls glowing from a cove light. Calm, serene, no people, no text.
Accept: an open oak door on the RIGHT clearly shows the en-suite shower.
- **`bathroom`**. Reference: LIVING.
> Photorealistic luxury interior photograph, wide 16:9, eye level, 24mm. Primary bathroom of the exact apartment in the reference image, entered through the oak pivot door: a freestanding pale stone bathtub centred against a full-height book-matched travertine wall, a concealed cove light above washing the stone in warm amber, a bronze freestanding tub filler, a long floating oak vanity on the left wall, and on the right a curved floor-to-ceiling window looking over the sea in deep blue dusk light with a glass balcony railing outside. Pale travertine floor. Serene, spa-like, no people, no text.
Accept: the tub is centred on the travertine wall, with the sea window on the right.
**2f. `shower`.** Do this after choosing the bedroom. Generate 2 variants, referencing your chosen BEDROOM:
> Photorealistic luxury interior photograph, wide 16:9, eye level, 24mm. The en-suite shower room seen through the open oak door on the right of the bedroom in the reference image (same apartment, same warm travertine, white oak, bronze fittings, amber cove lighting, blue-hour evening). The camera has stepped inside: a large walk-in shower behind a single frameless glass panel, full-height book-matched travertine walls, a ceiling-mounted bronze rainfall shower head and a bronze hand shower, a lit recessed travertine niche with two amber glass bottles, a linear floor drain; on the left a floating white-oak vanity with a travertine basin, a bronze wall tap and a backlit mirror; on the far wall a narrow floor-to-ceiling window showing the sea in deep blue dusk light. Pale travertine floor, a folded cream towel. Serene, spa-like, no people, no text.
Accept: it matches the shower glimpsed through the bedroom door.
Show me all 7 chosen stills in one `show_generation_by_ids` call. If REVIEW_STILLS is "on", stop here.
## STEP 3 — The five transition clips (start and end frames locked)
Submit all five in one `generate_video_batch`. Each uses `kling4_0`, mode `image-to-video`, 16:9, 1080p and the `medias` roles shown:
1. **`tower_to_living`** (8 s): `start_image` TOWER, `image_references` BALCONY (the ordered middle keyframe), `end_image` LIVING.
> Seamless cinematic FPV-smooth drone shot, single take. From the wide establishing view of the spiralling tower at blue hour, the camera pushes in across the marina water and rises along the facade, curving toward a mid-level apartment until its curved white balcony and open glass doors fill the frame (middle keyframe), then continues straight through the open doors into the softly lit living room and comes to rest on the final frame. Continuous motion, gentle acceleration then smooth deceleration, no cuts, no shake, consistent architecture, no people.
2. **`living_to_kitchen`** (5 s): `start_image` LIVING, `end_image` KITCHEN.
> Smooth gimbal walk-through, single continuous shot. From the balcony threshold the camera glides forward into the living room, passing beside the curved white sofa and travertine coffee table, heading straight toward the oak kitchen island at the back, and settles centred on the kitchen in the final frame. Eye level, steady, gentle ease-in and ease-out, natural parallax, lighting unchanged, no people.
3. **`living_to_bedroom`** (5 s): `start_image` LIVING, `end_image` BEDROOM.
> Smooth gimbal walk-through, single continuous shot. From the balcony threshold the camera glides forward across the living room past the left end of the curved white sofa, turns gently left through the open doorway on the left, and enters the primary bedroom, settling on the view of the bed and the curved sea-view window in the final frame. Eye level, steady, gentle ease-in and ease-out, natural parallax, lighting unchanged, no people.
4. **`living_to_bathroom`** (5 s): `start_image` LIVING, `end_image` BATHROOM.
> Smooth steadicam walk-through, one continuous shot. The camera glides forward from the balcony threshold, past the right side of the coffee table and the white armchair, toward the single tall oak pivot door on the right that stands open. It passes straight through that one open doorway and into the primary bathroom, ending on the freestanding stone bathtub centred against the warm travertine wall, with the sea window on the right. There is only ONE door and it stays still and solid; walls and furniture keep their exact shape; no duplicated panels. Eye level, steady, gentle ease-out, lighting unchanged, no people.
5. **`bedroom_to_shower`** (5 s): `start_image` BEDROOM, `end_image` SHOWER.
> Smooth gimbal walk-through, single continuous shot. From the bedroom view the camera glides forward and to the right past the foot of the bed and the bedside table, through the open tall oak door on the right, and into the en-suite shower room, settling on the travertine shower and vanity in the final frame. Eye level, steady, gentle ease-in and ease-out, natural parallax, lighting unchanged, no people.
**Check every clip** with `check.sh` (Step 4) and view its contact sheet. Accept a clip when:
- The first and last frames score **SSIM ≥ 0.85** against their stills.
- Nothing morphs: no doors doubling, walls appearing out of nowhere, or furniture changing shape.
If a clip fails, re-roll it once on Kling with this appended to its prompt: "There is only ONE door and it stays still and solid; walls and furniture keep their exact shape." If it fails again, try `minimax_h3` (`start_image` + `end_image`, 5 s) and keep the better of the two.
## STEP 4 — Post-process in the sandbox
Download the 7 chosen stills to `~/tour/src/<name>.png` (tower, balcony, living, kitchen, bedroom, bathroom, shower) and the 5 accepted clips to `~/tour/src/<clip_id>.mp4`. Then write these four helpers into `~/tour` exactly as given:
```bash
cat > ~/tour/check.sh <<'EOF'
#!/bin/bash
# check.sh <clip_id> <start_still> <end_still> -> qc/<clip_id>.jpg contact sheet + SSIM of first/last frame vs the stills
cd ~/tour; v=src/$1.mp4
d=$(ffprobe -v error -show_entries format=duration -of csv=p=0 $v)
ffmpeg -v error -y -i $v -vf "fps=$(python3 -c "print(12/$d)"),scale=300:-1,tile=4x3" -frames:v 1 -q:v 4 qc/$1.jpg
ffmpeg -v error -y -i $v -frames:v 1 /tmp/f0.png
ffmpeg -v error -y -sseof -0.2 -i $v -update 1 /tmp/f1.png
W=$(ffprobe -v error -select_streams v -show_entries stream=width -of csv=p=0 $v); H=$(ffprobe -v error -select_streams v -show_entries stream=height -of csv=p=0 $v)
a=$(ffmpeg -i /tmp/f0.png -i src/$2.png -lavfi "[1]scale=$W:$H[b];[0][b]ssim" -f null - 2>&1 | grep -o "All:[0-9.]*")
b=$(ffmpeg -i /tmp/f1.png -i src/$3.png -lavfi "[1]scale=$W:$H[b];[0][b]ssim" -f null - 2>&1 | grep -o "All:[0-9.]*")
echo "$1 first~$2 $a last~$3 $b dur=$d"
EOF
cat > ~/tour/lock.sh <<'EOF'
#!/bin/bash
# lock.sh <clip_id> <start_still> <end_still> <reverse_name>
# -> site/assets/<clip_id>.mp4 and site/assets/<reverse_name>.mp4 : 1920x1080, 24 fps, H.264, NO audio,
# first 0.375 s blended into the start still and last 0.375 s into the end still (pixel-locked ends)
set -e; cd ~/tour; mkdir -p tmp
n=$1; A=src/$2.png; B=src/$3.png; R=$4
D=$(ffprobe -v error -show_entries format=duration -of csv=p=0 src/$n.mp4); FD=0.375
ST=$(python3 -c "print(round($D-$FD-1/24,3))")
ffmpeg -v error -y -i src/$n.mp4 -loop 1 -t $D -i $A -loop 1 -t $D -i $B -filter_complex \
"[0:v]scale=1920:1080:flags=lanczos,setsar=1,fps=24[v];[1:v]scale=1920:1080:flags=lanczos,format=rgba,fade=t=out:st=0:d=$FD:alpha=1[a];[2:v]scale=1920:1080:flags=lanczos,format=rgba,fade=t=in:st=$ST:d=$FD:alpha=1[b];[v][a]overlay=shortest=1[v1];[v1][b]overlay=shortest=1,format=yuv420p[o]" \
-map "[o]" -an -c:v libx264 -preset veryfast -crf 18 -g 24 -movflags +faststart site/assets/$n.mp4
rm -rf tmp/$n && mkdir -p tmp/$n && ffmpeg -v error -y -i site/assets/$n.mp4 -q:v 2 tmp/$n/f_%04d.jpg
i=1; for f in $(ls tmp/$n | sort -r); do mv tmp/$n/$f tmp/$n/r_$(printf %04d $i).jpg; i=$((i+1)); done
ffmpeg -v error -y -framerate 24 -i tmp/$n/r_%04d.jpg -an -c:v libx264 -preset veryfast -crf 18 -g 24 -pix_fmt yuv420p -movflags +faststart site/assets/$R.mp4
rm -rf tmp/$n; echo "locked $n + $R"
EOF
cat > ~/tour/lit.py <<'EOF'
# lit.py src/tower.png site/assets/tower_lit.jpg -> "lights on" copy of the tower used for the floor hover glow
import sys, numpy as np
from PIL import Image
im = np.asarray(Image.open(sys.argv[1]).convert('RGB')).astype(np.float32) / 255
r, g, b = im[..., 0], im[..., 1], im[..., 2]
warm = np.clip((r - b) * 3, 0, 1)[..., None]
glass = (np.clip(1 - warm, 0, 1) * np.clip((b - r) * 2, 0, 1)[..., None])
out = (im * 1.18 + [.05, .03, -.01]) * (1 - warm) + (im * [1.75, 1.55, 1.15] + [.10, .06, 0]) * warm
out = out * (1 - glass * .55) + np.array([1, .72, .38]) * .55 * glass * .55
Image.fromarray((np.clip(out, 0, 1) * 255).astype(np.uint8)).resize((1920, 1080), Image.LANCZOS).save(sys.argv[2], quality=88)
EOF
cat > ~/tour/floormap.py <<'EOF'
# floormap.py src/tower.png -> floormap.png (960x540, grey = level*10), floors_preview.jpg, prints the floor count
import sys, numpy as np
from PIL import Image
src = Image.open(sys.argv[1] if len(sys.argv) > 1 else 'tower.png').convert('RGB')
im = np.asarray(src).astype(np.int32); H, W, _ = im.shape
r, g, b = im[..., 0], im[..., 1], im[..., 2]
sky = (b > r + 45) & (b > 100) & (g < b) # blue-hour sky
white = (im.min(2) > 140) & ((im.max(2) - im.min(2)) < 55) # white slab edges
ns = (~sky[: int(H * .7)]).sum(0); cols = np.where(ns > .5 * ns[: int(W * .7)].max())[0]
cols = cols[cols < int(W * .7)]; X0, X1 = max(0, cols.min() - 40), min(W, cols.max() + 40)
prof = np.convolve(white[:, X0:X1].sum(1), np.ones(5) / 5, 'same')
top = int(np.argmax(prof > .25 * prof.max())); gap = int(H * .02)
peaks = [y for y in range(top, H - 2) if prof[y] == prof[max(0, y - gap):y + gap].max() and prof[y] > .2 * prof.max()]
ys, xs = np.where(white); m = (xs >= X0) & (xs < X1); ys, xs = ys[m], xs[m]
curves, widths = [], []
for y0 in peaks:
p = np.array([0, 0, float(y0)])
for win in (16, 12, 9, 7):
k = np.abs(ys - np.polyval(p, xs)) <= win
if k.sum() < 40: break
p = np.polyfit(xs[k], ys[k], 2)
k = np.abs(ys - np.polyval(p, xs)) <= 6
if k.sum() < 300: continue
lo, hi = np.percentile(xs[k], 1), np.percentile(xs[k], 99)
if curves and np.polyval(p, (lo + hi) / 2) - np.polyval(curves[-1][0], (lo + hi) / 2) < gap: continue
curves.append((p, int(lo), int(hi))); widths.append(hi - lo)
med = np.median(widths)
for i, w in enumerate(widths):
if i > 3 and w > 1.25 * med: curves = curves[: i + 1]; break # podium canopy = the last line
K = len(curves)
fm = np.zeros((H, W), np.uint8)
for i in range(K - 1):
(p0, a0, b0), (p1, a1, b1) = curves[i], curves[i + 1]
lo, hi = min(a0, a1), min(max(b0, b1), X1)
for x in range(lo, hi + 1):
fm[int(np.polyval(p0, x)) + 5: int(np.polyval(p1, x)) + 5, x] = K - 1 - i # bottom band = level 1
for y in range(H):
cs = np.convolve((~sky[y, X0:X1]).astype(int), np.ones(9, int), 'same') >= 7
idx = np.where(cs)[0]
if len(idx) == 0: fm[y] = 0; continue
fm[y, : X0 + idx.min()] = 0; fm[y, X0 + idx.max() + 1:] = 0
small = np.asarray(Image.fromarray(fm).resize((960, 540), Image.NEAREST))
Image.fromarray((small * 10).astype(np.uint8), 'L').save('floormap.png', optimize=True)
viz = np.asarray(src).copy(); pal = [(255, 80, 80), (80, 255, 120), (80, 160, 255), (255, 220, 80)]
for L in range(1, K):
mm = fm == L; viz[mm] = (viz[mm] * .5 + np.array(pal[L % 4]) * .5).astype(np.uint8)
Image.fromarray(viz).resize((960, 540)).save('floors_preview.jpg', quality=80)
print('floors', K - 1, 'band', X0, X1)
EOF
chmod +x ~/tour/check.sh ~/tour/lock.sh
```
Then, from `~/tour`:
1. **Check** each clip, e.g. `./check.sh living_to_kitchen living kitchen`; the fly-in is `./check.sh tower_to_living tower living`.
2. **Web stills.** Run `convert src/<s>.png -resize '1920x1080!' -quality 90 site/assets/<s>.jpg` for tower, living, kitchen, bedroom, bathroom and shower. The balcony still is not shipped.
3. **Lock and reverse.** Run these as one background job, then confirm each `site/assets` clip starts and ends at SSIM ≥ 0.95 against its `.jpg` still and has no audio stream:
- `./lock.sh tower_to_living tower living living_to_tower`
- `./lock.sh living_to_kitchen living kitchen kitchen_to_living`
- `./lock.sh living_to_bedroom living bedroom bedroom_to_living`
- `./lock.sh living_to_bathroom living bathroom bathroom_to_living`
- `./lock.sh bedroom_to_shower bedroom shower shower_to_bedroom`
4. **Lit tower:** `python3 lit.py src/tower.png site/assets/tower_lit.jpg`
5. **Floor map:** `python3 floormap.py src/tower.png`. Note the printed floor count as **FLOORS** and view `floors_preview.jpg`.
- Each coloured band must sit on exactly one floor, between two white balcony edges.
- If bands straddle two floors or a floor is missing, adjust the `gap` factor (0.02) or the `white` threshold (140), re-run and look again.
6. **TOUR_LEVEL.** Find the floor the fly-in actually enters.
- Put frames from 15%, 30%, 45% and 55% of `src/tower_to_living.mp4` beside `floors_preview.jpg`.
- Follow the balcony the camera homes in on and count floors up from the podium.
- That number is **TOUR_LEVEL**. Get this right: a wrong floor number is the first thing people notice.
- It must fall inside the template's "Two bedrooms" band (roughly 23–65% of FLOORS). If it doesn't, edit the `TYPES` cut-offs so it does.
7. **Through-the-glass dim.** From the fly-in's contact sheet, note the fraction of the clip at which the camera crosses the balcony railing (usually 0.6–0.7). It is the `dip` value of `'tower>living'`; the reverse edge `'living>tower'` gets 1 minus that value.
8. **Upload** the 17 files in `site/assets`: 7 `.jpg` and 10 `.mp4` (all except floormap). Build `~/tour/media.json` mapping each file name to its public url, e.g. `{"tower.jpg": "https://d2ol7oe51mr4n9.cloudfront.net/…jpg", …}`.
## STEP 5 — The page
Write the template below to `~/tour/template.html` **exactly as given**, using a quoted heredoc. Then fill it with the helper after the template.
**Before filling, set the hotspot positions.**
- Draw a labelled 10% grid over `site/assets/living.jpg` and `site/assets/bedroom.jpg` and view the results.
- In `SCENES`, set each spot's `x` / `y` (percent of the frame) to the visual centre of its doorway: Bedroom, Kitchen and Bathroom in the living room, and En-suite in the bedroom.
- The defaults in the template fit the original build; move them only if your doorways sit elsewhere.
- Also update the two `dip` values from Step 4.7.
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Choose your floor</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Jost:wght@200;300;400;500&display=swap" rel="stylesheet">
<style>
/*
VOICE quiet, architectural, luxury-brochure
IDEA a sales-gallery model you point at, then walk into
PICTURE full-bleed tower at blue hour; floors light up under the cursor
COLOUR blue-hour navy, warm interior amber, pale brass accent
TYPE Jost 200-500, thin display numerals
*/
:root{--ink:#f6f3ec;--soft:rgba(246,243,236,.76);--glass:rgba(22,38,52,.36);--edge:rgba(255,255,255,.2);--accent:#ecd987;--accent-ink:#2a2414}
*{box-sizing:border-box;margin:0;padding:0}
html,body{height:100%;background:#0c1521;overflow:hidden}
body{color:var(--ink);font:400 15px/1.5 Jost,system-ui,-apple-system,"Segoe UI",sans-serif;-webkit-font-smoothing:antialiased}
button{font:inherit;color:inherit;background:none;border:0;cursor:pointer}
#vp{position:fixed;inset:0;overflow:hidden;background:#0c1521;touch-action:manipulation}
#stage{position:absolute;left:0;top:0}
#stage.pan{transition:left var(--pan,1s) cubic-bezier(.45,0,.2,1)}
#still,#xf,#stage video,#hl{position:absolute;inset:0;width:100%;height:100%;display:block}
#stage video{opacity:0;object-fit:fill;pointer-events:none}
#stage video.on{opacity:1}
#xf{opacity:0;transition:opacity .7s ease;pointer-events:none}
#hl{pointer-events:none;opacity:0;transition:opacity .35s ease;z-index:2}
#hl.on{opacity:1}
#dim{position:absolute;inset:0;background:#04070c;opacity:0;pointer-events:none;z-index:3}
#tick{position:absolute;z-index:4;transform:translateY(-50%);display:flex;align-items:center;gap:10px;font:300 20px/1 Jost;pointer-events:none;opacity:0;transition:opacity .25s,top .18s ease;text-shadow:0 1px 12px rgba(0,0,0,.35)}
#tick:before{content:"";width:30px;height:1px;background:var(--ink)}
#tick.on{opacity:1}
.spot{position:absolute;z-index:5;transform:translate(-50%,-50%);display:inline-flex;gap:9px;align-items:center;padding:7px 11px 7px 13px;border-radius:4px;background:rgba(28,28,30,.42);-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);border:1px solid rgba(255,255,255,.24);font:400 13px/1 Jost;opacity:0;pointer-events:none;transition:opacity .5s ease,background .2s}
.spot i{width:7px;height:7px;border-radius:50%;background:var(--ink);animation:pulse 2.4s infinite}
.spot:hover,.spot:focus-visible{background:rgba(28,28,30,.66)}
@keyframes pulse{0%{box-shadow:0 0 0 0 rgba(255,255,255,.55)}70%{box-shadow:0 0 0 9px rgba(255,255,255,0)}100%{box-shadow:0 0 0 0 rgba(255,255,255,0)}}
.ui-on .spot{opacity:1;pointer-events:auto}
#bar{position:fixed;z-index:10;left:0;right:0;top:0;display:flex;justify-content:space-between;align-items:center;padding:16px clamp(16px,2.4vw,32px);font-size:13px;pointer-events:none}
#bar>*{pointer-events:auto}
#back{opacity:0;transition:opacity .4s;pointer-events:none;text-shadow:0 1px 10px rgba(0,0,0,.4);padding:6px 0}
.ui-on #back{opacity:1;pointer-events:auto}
.at-tower #back,.at-tower #cap{display:none}
#back:hover,#reg:hover{text-decoration:underline;text-underline-offset:4px}
#reg{color:var(--ink);text-decoration:none;display:inline-flex;align-items:center;gap:8px;text-shadow:0 1px 10px rgba(0,0,0,.4);padding:6px 0}
#reg i{width:6px;height:6px;border-radius:50%;background:var(--ink)}
#panel{position:fixed;z-index:9;right:clamp(16px,4vw,64px);top:clamp(16px,8vh,96px);width:min(340px,calc(100vw - 32px));padding:28px 26px 24px;background:var(--glass);-webkit-backdrop-filter:blur(18px) saturate(1.1);backdrop-filter:blur(18px) saturate(1.1);border:1px solid var(--edge);border-radius:6px;transition:opacity .5s ease,transform .5s ease}
.inside #panel,.busy #panel{opacity:0;transform:translateX(18px);pointer-events:none}
#panel h1{font:300 46px/1.02 Jost;letter-spacing:-.01em}
.lede{font-size:13px;color:var(--soft);margin:12px 0 26px;max-width:28ch}
.lvl{display:flex;align-items:flex-end;gap:12px}
.lvl span{font-size:14px;padding-bottom:6px}
.lvl b{font:200 66px/.9 Jost;min-width:2ch}
#lvType{font:500 15px/1.3 Jost;margin-top:16px}
#lvText{font-size:13px;color:var(--soft);margin-top:4px;min-height:3em}
#tourNote{font-size:12px;color:var(--accent);margin-top:6px;min-height:1.2em}
#slider{-webkit-appearance:none;appearance:none;width:100%;height:24px;background:transparent;margin-top:14px;cursor:pointer}
#slider::-webkit-slider-runnable-track{height:2px;background:rgba(255,255,255,.35)}
#slider::-moz-range-track{height:2px;background:rgba(255,255,255,.35)}
#slider::-webkit-slider-thumb{-webkit-appearance:none;width:16px;height:16px;border-radius:50%;background:var(--accent);margin-top:-7px;box-shadow:0 0 0 4px rgba(236,217,135,.18)}
#slider::-moz-range-thumb{width:16px;height:16px;border:0;border-radius:50%;background:var(--accent)}
#slider:focus-visible{outline:1px dashed var(--soft);outline-offset:4px}
.ends{display:flex;justify-content:space-between;font-size:11px;color:var(--soft)}
#enter{margin-top:18px;padding:11px 24px;background:var(--accent);color:var(--accent-ink);border-radius:3px;font:500 13px/1 Jost;letter-spacing:.05em;transition:filter .2s}
#enter:hover{filter:brightness(1.07)}
#enter:focus-visible,.spot:focus-visible,#back:focus-visible{outline:2px solid var(--accent);outline-offset:3px}
#cap{position:fixed;z-index:8;left:clamp(20px,5vw,72px);bottom:clamp(24px,8vh,88px);max-width:min(600px,88vw);opacity:0;transform:translateY(10px);transition:opacity .7s ease,transform .7s ease;pointer-events:none;text-shadow:0 1px 26px rgba(0,0,0,.38)}
.ui-on #cap{opacity:1;transform:none}
#scrim{position:fixed;inset:0;z-index:7;pointer-events:none;background:linear-gradient(to top,rgba(14,10,6,.58) 0%,rgba(14,10,6,.2) 24%,transparent 44%),linear-gradient(to bottom,rgba(10,10,12,.28),transparent 14%);opacity:0;transition:opacity .7s ease}
.inside.ui-on #scrim{opacity:1}
#cap h2{font:200 clamp(36px,4.8vw,64px)/1.02 Jost;letter-spacing:-.01em}
#cap p{font-size:14px;color:var(--soft);margin-top:12px;max-width:44ch}
#loader{position:fixed;inset:0;z-index:20;display:grid;place-items:center;background:#0c1521;font:300 13px Jost;letter-spacing:.2em;color:var(--soft);transition:opacity .8s}
#loader.gone{opacity:0;pointer-events:none}
@media (max-width:700px){
#panel{left:12px;right:12px;top:auto;bottom:12px;width:auto;padding:18px 18px 16px}
#panel h1{font-size:28px}
.lede{display:none}
.lvl b{font-size:46px}
#lvText{min-height:0}
#cap{bottom:24px}
#cap p{font-size:13px}
}
@media (prefers-reduced-motion:reduce){.spot i{animation:none}}
</style>
</head>
<body class="at-tower">
<div id="vp">
<div id="stage">
<img id="still" alt="The tower at dusk across the marina">
<img id="xf" alt="">
<canvas id="hl" width="1920" height="1080"></canvas>
<div id="dim"></div>
<div id="tick"></div>
<div id="spots"></div>
</div>
</div>
<header id="bar">
<button id="back" type="button">Back to the tower</button>
<a id="reg" href="#">Register interest <i></i></a>
</header>
<aside id="panel" aria-label="Choose your floor">
<h1>Choose<br>your floor</h1>
<p class="lede">Point at a floor and its rooms light up. Click it, or slide to a level and press enter, and you go in through the glass.</p>
<div class="lvl"><span>Level</span><b id="lvNum"></b></div>
<div id="lvType">Two bedrooms</div>
<p id="lvText"></p>
<p id="tourNote"></p>
<input id="slider" type="range" min="1" max="99" step="1" value="1" aria-label="Level">
<div class="ends"><span>1</span><span id="maxL"></span></div>
<button id="enter" type="button">Enter</button>
</aside>
<div id="scrim"></div>
<section id="cap" aria-live="polite"><h2 id="capT"></h2><p id="capP"></p></section>
<div id="loader">LOADING</div>
<script>
{
/* ---------- assets ----------
ONLINE = true -> loads stills + clips from Higgsfield hosting (works by just opening this file)
ONLINE = false -> loads them from ./assets/ next to this file (the offline/self-hosted pack) */
const ONLINE = true;
const MEDIA = __MEDIA__; /* file name -> hosted URL (filled in by the build) */
const A = n => ONLINE ? MEDIA[n] : 'assets/' + n;
const REGISTER_URL = '#'; // put your enquiry form / mailto link here
const TOUR_LEVEL = __TOUR_LEVEL__; // the floor the fly-in actually lands on
const FLOORS = __FLOORS__; // floors traced in the floor map
/* ---------- floors (sample details - edit freely) ---------- */
const TYPES = [
{to:Math.round(FLOORS * .22), type:'One bedroom', text:'A one-bedroom residence, 860 sq ft, with a curved terrace over the marina.'},
{to:Math.round(FLOORS * .65), type:'Two bedrooms', text:'A two-bedroom residence, 1,380 sq ft, with a wraparound terrace facing the open sea.'},
{to:FLOORS - 2, type:'Three bedrooms', text:'A three-bedroom residence, 2,050 sq ft, with sea views on three sides.'},
{to:FLOORS, type:'Penthouse', text:'A full-floor penthouse, 4,200 sq ft, with a 360-degree terrace.'}
];
const typeOf = L => TYPES.find(t => L <= t.to);
/* ---------- scenes + transitions ---------- */
const SCENES = {
tower: {img:'tower.jpg', focus:.36},
living: {img:'living.jpg', focus:.5, title:'Level ' + TOUR_LEVEL + ', two bedrooms',
text:'The living room opens onto the curved terrace; the kitchen, the primary bedroom and the primary bathroom lead off it.',
back:['tower','Back to the tower'],
spots:[{to:'bedroom',label:'Bedroom',x:24.6,y:41},{to:'kitchen',label:'Kitchen',x:55.5,y:40},{to:'bathroom',label:'Bathroom',x:87.4,y:45}]},
kitchen: {img:'kitchen.jpg', focus:.5, title:'The kitchen',
text:'A long oak island under travertine, with the sea running along the curved glass.',
back:['living','Back to the living room']},
bedroom: {img:'bedroom.jpg', focus:.5, title:'The primary bedroom',
text:'The bed faces the curve of the window; the en-suite shower room is through the oak door.',
back:['living','Back to the living room'],
spots:[{to:'shower',label:'En-suite',x:86.5,y:42}]},
bathroom:{img:'bathroom.jpg', focus:.5, title:'The primary bathroom',
text:'A stone bath against book-matched travertine, beside a window to the sea.',
back:['living','Back to the living room']},
shower: {img:'shower.jpg', focus:.5, title:'The en-suite shower',
text:'A walk-in rain shower in warm travertine, with a slot window onto the water.',
back:['bedroom','Back to the bedroom']}
};
/* rate = playback speed. dip = darken as the camera passes through the glass (fly-in only) */
const EDGES = {
'tower>living': {clip:'tower_to_living.mp4', rate:1.3, dip:.66},
'living>tower': {clip:'living_to_tower.mp4', rate:1.45, dip:.34},
'living>kitchen': {clip:'living_to_kitchen.mp4', rate:1.4},
'kitchen>living': {clip:'kitchen_to_living.mp4', rate:1.4},
'living>bedroom': {clip:'living_to_bedroom.mp4', rate:1.4},
'bedroom>living': {clip:'bedroom_to_living.mp4', rate:1.4},
'living>bathroom':{clip:'living_to_bathroom.mp4',rate:1.4},
'bathroom>living':{clip:'bathroom_to_living.mp4',rate:1.4},
'bedroom>shower': {clip:'bedroom_to_shower.mp4', rate:1.4},
'shower>bedroom': {clip:'shower_to_bedroom.mp4', rate:1.4}
};
/* floor map: one grey value per level (level*10) at 960x540, traced from the tower's balcony slabs */
const FLOORMAP = '__FLOORMAP__';
const FW = 960, FH = 540;
/* ---------- elements ---------- */
const $ = id => document.getElementById(id);
const body = document.body, vp = $('vp'), stage = $('stage'), still = $('still'), xf = $('xf'),
hl = $('hl'), hctx = hl.getContext('2d'), dim = $('dim'), tick = $('tick'), spotsEl = $('spots'),
panel = $('panel'), slider = $('slider'), enterBtn = $('enter'), backBtn = $('back'),
capT = $('capT'), capP = $('capP'), loader = $('loader');
$('reg').href = REGISTER_URL;
const reduceMotion = matchMedia('(prefers-reduced-motion: reduce)').matches;
let cur = 'tower', busy = false, sel = TOUR_LEVEL, hover = 0;
/* ---------- layout: cover the viewport, keep the subject in view on narrow screens ---------- */
function layout(focus, ms) {
const vw = innerWidth, vh = innerHeight, s = Math.max(vw / 1920, vh / 1080), w = 1920 * s, h = 1080 * s;
let left = vw / 2 - focus * w; left = Math.min(0, Math.max(vw - w, left));
stage.style.width = w + 'px'; stage.style.height = h + 'px'; stage.style.top = (vh - h) / 2 + 'px';
if (ms) { stage.style.setProperty('--pan', ms + 'ms'); stage.classList.add('pan'); } else stage.classList.remove('pan');
stage.style.left = left + 'px';
}
addEventListener('resize', () => layout(SCENES[cur].focus, 0));
/* ---------- media caches ---------- */
const imgs = {}, vids = {};
function img(name) {
if (!imgs[name]) { const i = new Image(); i.src = A(name); imgs[name] = i; }
return imgs[name];
}
function vid(name) {
if (!vids[name]) {
const v = document.createElement('video');
v.muted = true; v.playsInline = true; v.preload = 'auto'; v.setAttribute('muted', ''); v.setAttribute('playsinline', '');
v.src = A(name); v.load();
v.addEventListener('error', () => { v.dataset.broken = '1'; });
stage.insertBefore(v, hl); vids[name] = v;
}
return vids[name];
}
const once = (el, ev, ms) => new Promise((res, rej) => {
const t = ms ? setTimeout(() => rej(new Error('timeout ' + ev)), ms) : 0;
el.addEventListener(ev, function f() { clearTimeout(t); el.removeEventListener(ev, f); res(); });
});
function preloadFrom(scene) {
Object.keys(EDGES).filter(k => k.startsWith(scene + '>')).forEach(k => { vid(EDGES[k].clip); img(SCENES[k.split('>')[1]].img); });
}
/* ---------- floor map + highlight ---------- */
let fm = null; const boxes = {}; let lit = null;
async function loadFloormap() {
const i = new Image(); i.src = FLOORMAP; await i.decode();
const c = document.createElement('canvas'); c.width = FW; c.height = FH;
const x = c.getContext('2d'); x.drawImage(i, 0, 0);
const d = x.getImageData(0, 0, FW, FH).data; fm = new Uint8Array(FW * FH);
for (let p = 0; p < FW * FH; p++) {
const L = Math.round(d[p * 4] / 10); fm[p] = L;
if (L) { const px = p % FW, py = (p / FW) | 0, b = boxes[L] || (boxes[L] = {x0: px, x1: px, y0: py, y1: py});
if (px < b.x0) b.x0 = px; if (px > b.x1) b.x1 = px; if (py < b.y0) b.y0 = py; if (py > b.y1) b.y1 = py; }
}
}
function levelAt(cx, cy) {
if (!fm) return 0;
const r = stage.getBoundingClientRect();
const x = Math.floor((cx - r.left) / r.width * FW), y = Math.floor((cy - r.top) / r.height * FH);
if (x < 0 || x >= FW || y < 0 || y >= FH) return 0;
for (const dy of [0, -2, 2, -4, 4]) { const yy = y + dy; if (yy >= 0 && yy < FH && fm[yy * FW + x]) return fm[yy * FW + x]; }
return 0;
}
const mk = document.createElement('canvas'), glow = document.createElement('canvas'), sharp = document.createElement('canvas');
function drawLevel(L) {
hctx.clearRect(0, 0, 1920, 1080);
const b = boxes[L];
if (!b || !lit || !lit.complete) { tick.classList.remove('on'); return; }
const w = b.x1 - b.x0 + 1, h = b.y1 - b.y0 + 1;
mk.width = w; mk.height = h; const m = mk.getContext('2d'), id = m.createImageData(w, h);
for (let y = 0; y < h; y++) for (let x = 0; x < w; x++) if (fm[(b.y0 + y) * FW + b.x0 + x] === L) id.data[(y * w + x) * 4 + 3] = 255;
m.putImageData(id, 0, 0);
const X = b.x0 * 2, Y = b.y0 * 2, W = w * 2, H = h * 2, P = 48;
glow.width = W + P * 2; glow.height = H + P * 2; const g = glow.getContext('2d');
g.filter = 'blur(16px)'; g.drawImage(mk, P, P, W, H); g.filter = 'none';
g.globalCompositeOperation = 'source-in'; g.fillStyle = '#ffb661'; g.fillRect(0, 0, glow.width, glow.height);
sharp.width = W; sharp.height = H; const s = sharp.getContext('2d');
s.filter = 'blur(1.2px)'; s.drawImage(mk, 0, 0, W, H); s.filter = 'none';
s.globalCompositeOperation = 'source-in'; s.drawImage(lit, X, Y, W, H, 0, 0, W, H);
hctx.globalAlpha = .85; hctx.globalCompositeOperation = 'screen'; hctx.drawImage(glow, X - P, Y - P);
hctx.globalAlpha = 1; hctx.globalCompositeOperation = 'source-over'; hctx.drawImage(sharp, X, Y);
hctx.globalAlpha = .22; hctx.globalCompositeOperation = 'screen'; hctx.drawImage(sharp, X, Y);
hctx.globalAlpha = 1; hctx.globalCompositeOperation = 'source-over';
tick.textContent = L;
tick.style.left = ((b.x1 * 2 + 26) / 1920 * 100) + '%';
tick.style.top = (((b.y0 + b.y1)) / 1080 * 100) + '%';
tick.classList.add('on'); hl.classList.add('on');
}
function setPanel(L) {
const t = typeOf(L);
$('lvNum').textContent = L; $('lvType').textContent = t.type; $('lvText').textContent = t.text;
$('tourNote').textContent = L === TOUR_LEVEL ? '' : 'Enter tours the Level ' + TOUR_LEVEL + ' show residence';
slider.value = L;
}
function select(L) { sel = Math.max(1, Math.min(FLOORS, L)); setPanel(sel); drawLevel(hover || sel); }
/* ---------- scene UI ---------- */
function showUI(scene) {
const S = SCENES[scene];
body.classList.toggle('inside', scene !== 'tower');
body.classList.toggle('at-tower', scene === 'tower');
capT.textContent = S.title || ''; capP.textContent = S.text || '';
backBtn.textContent = S.back ? S.back[1] : '';
spotsEl.innerHTML = '';
(S.spots || []).forEach(sp => {
const b = document.createElement('button');
b.type = 'button'; b.className = 'spot'; b.style.left = sp.x + '%'; b.style.top = sp.y + '%';
b.setAttribute('aria-label', 'Go to the ' + sp.label.toLowerCase());
const t = document.createElement('span'); t.textContent = sp.label; b.append(t, document.createElement('i'));
b.addEventListener('click', e => { e.stopPropagation(); go(sp.to); });
spotsEl.append(b);
});
if (scene === 'tower') { drawLevel(sel); }
setTimeout(() => { if (!busy) body.classList.add('ui-on'); }, scene === 'tower' ? 0 : 280);
}
function hideUI() { body.classList.remove('ui-on'); body.classList.add('busy'); tick.classList.remove('on'); }
/* ---------- the transition: still -> locked clip -> still ---------- */
function runDip(v, at) {
const f = () => {
if (v.paused || v.ended) { dim.style.opacity = 0; return; }
const p = v.currentTime / (v.duration || 1), d = Math.max(0, 1 - Math.abs(p - at) / .14);
dim.style.opacity = (d * d * (3 - 2 * d) * .55).toFixed(3);
requestAnimationFrame(f);
};
requestAnimationFrame(f);
}
async function crossfade(to) {
const n = img(SCENES[to].img); await n.decode().catch(() => {});
xf.src = n.src; xf.style.transition = 'none'; xf.style.opacity = 0; xf.offsetWidth;
xf.style.transition = ''; xf.style.opacity = 1; await new Promise(r => setTimeout(r, 720));
still.src = n.src; await still.decode().catch(() => {}); xf.style.opacity = 0;
}
async function go(to) {
if (busy || to === cur) return;
const e = EDGES[cur + '>' + to]; if (!e) return;
busy = true; hideUI(); hl.classList.remove('on');
const next = img(SCENES[to].img);
const v = vid(e.clip);
try {
if (reduceMotion || v.dataset.broken) throw new Error('fallback');
if (v.currentTime > 0.04) v.currentTime = 0;
v.playbackRate = e.rate;
const firstFrame = new Promise(res => {
if ('requestVideoFrameCallback' in v) v.requestVideoFrameCallback(() => res());
else v.addEventListener('playing', function f() { v.removeEventListener('playing', f); res(); });
});
const timeout = new Promise((_, rej) => setTimeout(() => rej(new Error('slow')), 25000));
await Promise.race([v.play(), timeout]); /* play() inside the click = works on iOS too */
await Promise.race([firstFrame, timeout]);
v.classList.add('on'); /* frame 0 == current still: invisible swap */
const dur = (v.duration || 5) / e.rate * 1000;
layout(SCENES[to].focus, dur); /* pan the crop with the move on narrow screens */
if (e.dip) runDip(v, e.dip);
await once(v, 'ended');
await next.decode().catch(() => {});
still.src = next.src; await still.decode().catch(() => {});
v.classList.remove('on'); dim.style.opacity = 0; /* last frame == next still: invisible swap */
} catch (err) {
v.classList.remove('on'); dim.style.opacity = 0;
layout(SCENES[to].focus, 0);
await crossfade(to);
}
cur = to; busy = false; body.classList.remove('busy');
showUI(to); preloadFrom(to);
}
/* ---------- input ---------- */
vp.addEventListener('pointermove', e => {
if (cur !== 'tower' || busy || e.pointerType === 'touch') return;
const L = levelAt(e.clientX, e.clientY);
vp.style.cursor = L ? 'pointer' : '';
if (L !== hover) { hover = L; if (L) setPanel(L); else setPanel(sel); drawLevel(L || sel); }
});
vp.addEventListener('pointerleave', () => { if (cur === 'tower' && hover) { hover = 0; setPanel(sel); drawLevel(sel); } });
vp.addEventListener('click', e => {
if (cur !== 'tower' || busy) return;
const L = levelAt(e.clientX, e.clientY); if (!L) return;
if (L !== sel) { hover = 0; select(L); if (e.pointerType === 'touch' || matchMedia('(hover: none)').matches) return; }
go('living');
});
slider.addEventListener('input', () => { hover = 0; select(+slider.value); });
enterBtn.addEventListener('click', () => go('living'));
backBtn.addEventListener('click', () => { const b = SCENES[cur].back; if (b) go(b[0]); });
addEventListener('keydown', e => {
if (busy) return;
if (cur === 'tower') {
if (e.key === 'ArrowUp' || e.key === 'ArrowRight') { e.preventDefault(); hover = 0; select(sel + 1); }
else if (e.key === 'ArrowDown' || e.key === 'ArrowLeft') { e.preventDefault(); hover = 0; select(sel - 1); }
else if (e.key === 'Enter' && document.activeElement !== backBtn) { e.preventDefault(); go('living'); }
} else if (e.key === 'Escape' || e.key === 'Backspace') { const b = SCENES[cur].back; if (b) go(b[0]); }
});
/* ---------- boot ---------- */
(async () => {
layout(SCENES.tower.focus, 0);
setTimeout(() => loader.classList.add('gone'), 8000); /* never hang on the loading screen */
still.src = A('tower.jpg');
lit = img('tower_lit.jpg');
await Promise.all([still.decode().catch(() => {}), loadFloormap().catch(() => {}), lit.decode().catch(() => {})]);
slider.max = FLOORS; $('maxL').textContent = FLOORS;
setPanel(sel); showUI('tower');
loader.classList.add('gone');
preloadFrom('tower');
['living.jpg', 'kitchen.jpg', 'bedroom.jpg', 'bathroom.jpg', 'shower.jpg'].forEach(img);
})();
}
</script>
</body>
</html>
```
Fill the template with this helper. It writes `site/index.html`, which loads `./assets` and works offline, and `site/index-online.html`, which streams from Higgsfield:
```bash
cat > ~/tour/fill.py <<'EOF'
# fill.py floormap.png <FLOORS> <TOUR_LEVEL>
import json, sys, base64
t = open('template.html').read()
media = json.load(open('media.json'))
fm = 'data:image/png;base64,' + base64.b64encode(open(sys.argv[1], 'rb').read()).decode()
out = (t.replace('__MEDIA__', json.dumps(media, indent=2)).replace('__FLOORMAP__', fm)
.replace('__FLOORS__', sys.argv[2]).replace('__TOUR_LEVEL__', sys.argv[3]))
assert '__' not in out, 'unfilled placeholder'
open('site/index-online.html', 'w').write(out)
open('site/index.html', 'w').write(out.replace('const ONLINE = true;', 'const ONLINE = false;'))
print('page written', len(out))
EOF
cd ~/tour && python3 fill.py floormap.png <FLOORS> <TOUR_LEVEL>
```
## STEP 6 — Test, package, deliver
**1. Test in a real browser.** Run this as a background job and read its output:
```bash
cat > /tmp/tour_test.js <<'EOF'
const { chromium } = require('playwright');
(async () => {
const b = await chromium.launch();
for (const f of ['index.html', 'index-online.html']) {
const p = await b.newPage({ viewport: { width: 1440, height: 810 } });
const errs = []; p.on('pageerror', e => errs.push(e.message));
await p.goto('file:///home/user/tour/site/' + f);
await p.waitForSelector('#loader.gone', { timeout: 30000 }); await p.waitForTimeout(600);
await p.screenshot({ path: `/home/user/tour/qc/${f}_tower.png` });
const ready = () => p.waitForFunction(() => !document.body.classList.contains('busy') && document.body.classList.contains('ui-on'), null, { timeout: 40000 });
await p.click('#enter'); await ready(); await p.waitForTimeout(800);
await p.screenshot({ path: `/home/user/tour/qc/${f}_living.png` });
const log = [await p.textContent('#capT')];
for (const s of ['Kitchen', 'back', 'Bathroom', 'back', 'Bedroom', 'En-suite', 'back', 'back', 'back']) {
if (s === 'back') await p.click('#back'); else await p.click(`.spot:has-text("${s}")`);
await ready(); log.push((await p.textContent('#capT')) || 'TOWER');
}
console.log(f, '|', log.join(' > '), '| errors:', errs.length ? errs : 'none');
await p.close();
}
await b.close();
})().catch(e => { console.error('FAIL', e.message); process.exit(1); });
EOF
cd /tmp && NODE_PATH=$(npm root -g) node tour_test.js
```
Both pages must walk Level N → kitchen → back → bathroom → back → bedroom → en-suite → back → back → TOWER with `errors: none`. Shrink the four `qc/*_tower.png` / `qc/*_living.png` screenshots to JPG and look at them:
- The panel sits on the right over clear sky.
- The floor marker sits next to the right floor.
- The three labels sit on their doorways.
- The caption is readable.
Fix anything that fails and test again.
**2. Walkthrough reel (silent, about 42 s, 1080p)** for social posts:
```bash
cat > ~/tour/reel.sh <<'EOF'
#!/bin/bash
set -e; cd ~/tour; mkdir -p reel pack; S=1.3
hold(){ ffmpeg -v error -y -loop 1 -t $2 -i site/assets/$1.jpg -vf "scale=1920:1080,fps=24,format=yuv420p" -c:v libx264 -preset veryfast -crf 17 -g 24 reel/$3.mp4; }
clip(){ ffmpeg -v error -y -i site/assets/$1.mp4 -vf "setpts=PTS/$S,fps=24,format=yuv420p" -an -c:v libx264 -preset veryfast -crf 17 -g 24 reel/$2.mp4; }
hold tower 2.0 a01; clip tower_to_living a02; hold living 1.4 a03
clip living_to_bedroom a04; hold bedroom 1.0 a05; clip bedroom_to_shower a06; hold shower 1.4 a07
clip shower_to_bedroom a08; clip bedroom_to_living a09; clip living_to_kitchen a10; hold kitchen 1.2 a11
clip kitchen_to_living a12; clip living_to_bathroom a13; hold bathroom 2.0 a14
(cd reel && ls a*.mp4 | sed "s/^/file '/;s/$/'/" > list.txt && ffmpeg -v error -y -f concat -safe 0 -i list.txt -c copy raw.mp4)
D=$(ffprobe -v error -show_entries format=duration -of csv=p=0 reel/raw.mp4)
ffmpeg -v error -y -i reel/raw.mp4 -vf "fade=t=in:st=0:d=0.6,fade=t=out:st=$(python3 -c "print($D-0.8)"):d=0.8" -an -c:v libx264 -preset veryfast -crf 17 -g 48 -pix_fmt yuv420p -movflags +faststart pack/tour_walkthrough.mp4
echo "reel $D s"
EOF
chmod +x ~/tour/reel.sh && ~/tour/reel.sh
```
**3. Package.** Write `site/README.txt`, which says:
- Unzip, then double-click `index.html`. It works offline; `index-online.html` streams from Higgsfield.
- Open the page in a browser. In-chat previews block video and sit on "Loading".
- To publish, upload the folder to any static host (Netlify, Vercel, S3).
- What to edit at the top of the script:
- `TYPES`: unit text, which is sample copy
- `SCENES`: titles, captions and hotspot x/y
- `EDGES`: clip, speed and dip for each transition
- `REGISTER_URL`
- `TOUR_LEVEL`
- How to add a room: make a still matched to the room you leave from, generate a Kling start+end clip, run `lock.sh`, then add one scene and two edges.
Then run `cd ~/tour && rm -rf pack/tower-tour && cp -r site pack/tower-tour && rm -f pack/tower-tour/assets/floormap.png && (cd pack && zip -q -r -0 tower-tour.zip tower-tour)`.
Upload `pack/tower-tour.zip` (type `file`) and `pack/tour_walkthrough.mp4` (type `video`). Check that both public URLs return HTTP 200 with `curl -sI`.
**4. Deliver.** Reply to me with:
- The zip link and the reel link.
- One line on opening it: unzip and double-click `index.html` in Chrome or Safari, not in a chat preview.
- Which floor the fly-in enters (TOUR_LEVEL), with a request to tell you if I count a different floor so you can change the number.
- Credits used, from `balance` before and after.
Don't paste the HTML into the chat.
## DONE WHEN
- [ ] 7 stills chosen against their criteria and shown to me.
- [ ] 5 clips pass QC: SSIM ≥ 0.85 at both ends and no morphing.
- [ ] 10 locked clips (5 forward + 5 reverse) at 1920×1080, 24 fps, no audio, with both ends at SSIM ≥ 0.95 against their stills.
- [ ] The floor bands sit on real floors, TOUR_LEVEL matches the fly-in, and the hotspots sit on their doorways.
- [ ] Both pages pass the browser test with no errors, and you have looked at the screenshots.
- [ ] Zip and reel are hosted and their links return 200, with the final message sent.
If any step fails, fix it and continue from that step. Don't start over.Make it yours
| Swap | How |
|---|---|
| Your own location | Change SETTING at the top, e.g. a snowy alpine lake or a city skyline at dusk. The prompts keep every camera and framing instruction. |
| Your own building | Change TOWER and APARTMENT. Keep the right third of the tower shot clear, because the floor panel sits there. |
| Your own floor plan | Edit TYPES in the page script: floor bands, unit types and the text in the panel. TOUR_LEVEL sets the floor the fly-in lands on. |


