Picking rooms with taps in 3D, independent lamp states and timed day-to-night fades.
Picking rooms with taps in 3D, independent lamp states and timed day-to-night fades.
No runs posted yet. Be the first: post yours and tag @wikiwayne.
DOLLHOUSE CUTAWAY: Three Rooms, Tap to Light, Day to Night
HOOK OBJECT: window.__dollhouse
Build "DOLLHOUSE CUTAWAY": a three-storey wooden toy dollhouse with its front open like a stage, sitting on a table, with a furnished room on each floor. Tap a room to switch its lamp on or off, and flip the whole scene from day to night to watch the lit rooms glow like little theatre sets. It is cozy and fun to keep watching because every lamp you light changes the mood.
LOOK
- Style: warm toy-wood diorama, matte painted plywood and felt, soft shadows (Three.js, PCF soft shadow map 2048). Palette: house frame #D9A066, roof #8E3B46, table #6B4B35, felt mat #3C6E71, floor boards #B98B5E, kitchen walls #BFE0D3, study walls #F4E3C1, bedroom walls #F2C6C2, lamp glow #FFC46B. Day sky #BFE3F5, night sky #0E1830.
- Dimensions in world units (u): each room is 4.0 wide (x -2 to 2), 2.4 tall and 2.8 deep (z -1.4 to 1.4) with the front (z = +1.4) open and walls 0.2 thick. Stack from the bottom: base slab 0.2, kitchen, slab 0.15, study, slab 0.15, bedroom, then a gable roof (two sloped slabs, ridge at y = 9.1, overhang 0.3). The house is 5.0 u wide including the roof and 9.1 u tall. The table is 18 x 12 u under it with 5 toy blocks and one potted plant around the house.
- Kitchen (bottom): checkered floor #E8D9B5 and #CDB98E, a counter along the back wall (3.0 x 0.9 x 0.7, #C8553D with a white top), a fridge (0.7 x 1.7 x 0.7), a round table with two chairs, a hanging lamp. Study (middle): a desk with a chair, a bookshelf with 24 small books in different colors, a globe on a stand, a rug, a table lamp. Bedroom (top): a bed with quilt and pillow, a wardrobe, a round rug, a nightstand with a lamp. Each room has a window on its back wall that shows the sky color, with a glowing moon at night.
- Each room has ONE lamp: a glowing bulb plus a warm point light (#FFC46B, short reach about 4 u so it lights its own room much more than the rooms above and below).
- Lighting at day: a sun light of intensity 2.0 and an ambient light of 0.9. At night: sun 0.15 (a cool moonlight #6A7BC8) and ambient 0.12, plus a sprinkle of stars and a moon behind the house. Rooms with their lamp off stay faintly readable at night.
- Camera: default azimuth 0 degrees, elevation 8 degrees, distance 21 u, looking at (0, 4.5, 0), vertical field of view 30 degrees. On a narrow window (width / height below 0.6) the distance grows so the 5.0 u house width fills at most 90% of the screen width.
- HUD: one line at the top-left, 14 px bold, "LIGHTS ON n/3 · SWITCHED n · NIGHTS n · DAYS n", inside the top margin above the roof. A 56 px round NIGHT / DAY button sits at the bottom-right, clear of the house. Neither overlaps the house.
- FIRST FRAME (t = 0, no input): daytime, all three lamps off, the camera at its default, the whole house centered with its height at least 70% of the screen height (about 85% at 1280x720), every room clearly visible with its furniture.
MOTION / PLAY
- Controls: tap or click a room to switch its lamp (a tap is a press and release within 250 ms that moves less than 6 px). Dragging orbits the camera: 0.25 degrees of azimuth per px (clamped to +/-40), 0.15 degrees of elevation per px (clamped 4 to 30). Pinch or wheel changes the distance (14 to 30 u). Keys 1, 2, 3 switch the kitchen, study and bedroom lamps; N toggles night. The NIGHT / DAY button toggles night.
- A lamp fades linearly to its new state in 0.4 s. Rooms are independent: switching one never changes the others, and switching day to night never changes any lamp's state.
- Day / night fades the whole scene linearly over 2.0 s (sky color, sun and ambient intensity, stars, window glass, moon). Pressing it again mid-fade turns around from the current value.
- The hook exposes tapRoom(i) (i = 0 kitchen, 1 study, 2 bedroom; same code path as a real tap), setNight(bool) (starts the 2.0 s fade, no effect if already there), attract(on) (false turns the demo off), lighting() returning { sky, sun, ambient, rooms: [a, b, c] } where sky is 0 at full day and 1 at full night, sun and ambient are the current light intensities, and rooms are the 3 current lamp levels from 0 to 1, houseRect() returning { x, y, w, h } of the house's on-screen bounding box in CSS px, roomScreenPoint(i) returning { x, y } of the center of room i's open front in CSS px, and getCameraOrbit() returning { azimuth, elevation, distance }. Hook calls are not user input and do not pause the demo.
- ATTRACT MODE: with no input, a hands-free demo starts on load and loops every 28 s. The camera sways: azimuth = 18 degrees x sin(2 pi t / 28). Schedule: day for 0-4 s; dusk fade 4-6 s; at 7.0 s the kitchen lamp goes on, at 9.0 s the study lamp, at 11.0 s the bedroom lamp; at 20.0 s the study lamp goes off, at 22.0 s the bedroom lamp goes off; dawn fade 24-26 s; at 25.0 s the kitchen lamp goes off; hold until 28.0 s, then everything cuts to the t = 0 state (4 + 2 + 18 + 2 + 2 = 28 s). Demo switches use the same code path as a real tap and show a soft expanding glow ring (0.5 s) at the lamp. Any input takes over; the demo resumes after 8 s with no input.
SOUND
- A room tap → a wooden "tock" (180 Hz, 90 ms), then a bright "tink" (1.2 kHz, 80 ms) when the lamp goes on or a dull "tunk" (300 Hz, 80 ms) when it goes off.
- Night fade complete → soft cricket chirps (4.2 kHz bursts every 0.35 s) that keep going while sky is above 0.9.
- Day fade complete → two short bird chirps (2.4 kHz and 3.0 kHz, 70 ms).
- A drag → nothing (no sound while orbiting).
COUNTERS
stats() returns { fps, lightsOn, toggles, nights, days }.
- lightsOn: the number of rooms whose lamp switch is currently on (0 to 3), updated at the instant of the switch, not after the 0.4 s fade.
- toggles: +1 each time a lamp is switched on or off by a tap, key or the demo. Dragging never counts. Never on load.
- nights: +1 each time a day-to-night fade finishes (sky reaches 1).
- days: +1 each time a night-to-day fade finishes (sky reaches 0). The day shown at load is not counted.
- On screen: lightsOn, toggles, nights and days in the HUD line, readable in a paused frame.
CHECKS for ?test=1
With ?test=1, run an accelerated self-test that measures real positions and real events (not self-set flags) and logs "TEST n PASS" or "TEST n FAIL: reason" to the console and to window.__testResults:
Each check starts from a fresh load; advance() steps in 1/60 s increments.
1. At t = 0 there is exactly one canvas filling the window; lighting() is { sky 0, sun 2.0, ambient 0.9, rooms [0, 0, 0] } (each within 0.05); houseRect() is fully inside the window, its height is at least 70% of the window height and its center is within 5% of the window width of the middle; getCameraOrbit().distance is 21 (within 0.1) at 1280x720; roomScreenPoint(0..2) y values are in descending order of room height (kitchen lowest on screen) and each is at least 0.18 x window height apart; stats() is { lightsOn 0, toggles 0, nights 0, days 0 }.
2. After attract(false): a real pointerdown and pointerup (within 100 ms, no movement) at roomScreenPoint(1) gives toggles 1 and lightsOn 1, and after advance(0.5) lighting().rooms is [0, at least 0.99, 0]; then a real drag (pointerdown at roomScreenPoint(2), pointermove 80 px to the right, pointerup) leaves toggles at 1 and changes getCameraOrbit().azimuth by at least 5 degrees.
3. After attract(false): tapRoom(0), then advance(0.2) gives rooms[0] between 0.4 and 0.6, and advance(0.3) more gives at least 0.99; tapRoom(0) again, advance(0.2) gives between 0.4 and 0.6 and advance(0.3) more gives at most 0.01; toggles is 2 and lightsOn is 0.
4. After attract(false): tapRoom(2), setNight(true), advance(1.0) gives sky between 0.45 and 0.55; advance(1.2) more (t = 2.2) gives sky at least 0.99, sun at most 0.2, ambient at most 0.2, nights 1, days 0, and rooms[2] at least 0.99; then setNight(false), advance(2.2) gives sky at most 0.01, sun at least 1.95, days 1, rooms[2] still at least 0.99 and toggles still 1.
5. On a fresh load with the demo running: at t = 6.5 nights is 1 and toggles is 0; at t = 7.6 toggles is 1, lightsOn is 1, rooms[0] is at least 0.99 and rooms[1] is 0; at t = 11.6 toggles is 3 and lightsOn is 3; at t = 20.6 toggles is 4, lightsOn is 2 and rooms[1] is at most 0.01; at t = 26.6 toggles is 6, lightsOn is 0, days is 1 and sky is at most 0.01; the run has zero console errors.
KEEP IT SHORT
- Keep the whole file under about 1,500 lines (soft target) so you can write it in one pass and finish well inside 15 minutes.
- Save lines with helpers, loops and instancing, not by dropping features. Everything above must really work: no placeholders, no TODOs.
BUILD RULES (all required):
- Deliver ONE self-contained HTML file: inline CSS and JS, no build step, no local assets. Libraries only from a CDN. If you use Three.js, use exactly this import map: {"imports":{"three":"https://cdn.jsdelivr.net/npm/three@0.160.0/build/three.module.js","three/addons/":"https://cdn.jsdelivr.net/npm/three@0.160.0/examples/jsm/"}}
- It must open straight from disk in desktop Chrome and on an iPhone (Safari), fill the full screen, handle resize and touch, and stay smooth (target 60 fps).
- It must look stunning in the very FIRST frame: no black screen, no loading wait, no tiny subject. The main subject fills at least 50% of the screen height.
- SOUND (required): all sound is made in code with Web Audio (no audio files). Show a small "🔊 TAP FOR SOUND" chip; on the first tap create ONE AudioContext, route everything through a master gain of 0.6 into a DynamicsCompressor, and hide the chip. Also expose enableAudio() on the hook object named at the top.
- Expose the hook object named at the top with: setCameraOrbit(azimuthDeg, elevationDeg, distance) (or an equivalent camera setter), advance(seconds) that steps the simulation exactly that much for still captures, enableAudio(), and stats() returning {fps, ...the counters named above}. Use a fixed random seed of 360 so every run is the same.
- Every on-screen counter must count a real event you can see happen. No fake numbers.
- No text overlapping the subject; any label must be readable in a paused frame.
- No brand logos, no real people, no copyrighted characters, brand names or logos.
FAILURE MODES TO AVOID
- A house with a closed front so you cannot see into the rooms, or a camera so far back that the house is tiny.
- A tap that hits the wrong room, hits nothing, or toggles when the user was dragging to orbit.
- A lamp that snaps on with no fade, or a lamp light that floods the other rooms as much as its own.
- Switching day to night that also switches the lamps, or a lamp state that depends on the time of day.
- A night scene so dark that nothing is readable, or a night that looks the same as the day.
- A lamp bulb that glows while its light is off, or a light that stays on while its bulb looks dark.
- Counters that tick on a timer, or toggles that go up when you only drag.
- Shadow acne, walls that let the sun through, or furniture floating above or sunk into floors.
- Text over the house, or a HUD too small to read.
- The same variable declared twice, or methods called on objects that don't exist yet.
SELF-TEST LOOP
- If you can run code: build the file, open it, read the console, run ?test=1, and take screenshots at 3 s, 10 s and 30 s at 1280x720 and 390x844. Look at the screenshots and fix what looks wrong. Fix and retest until all 5 checks pass with zero console errors. Mark anything you could not run as UNMEASURED; never invent results.
- If you are chat-only: go through this prompt line by line, check your code against each line, and fix anything that would fail. Then write one corrected, complete file.
- Final answer: ONE complete HTML file in ONE code block, then the 5 checks marked PASS, FAIL or UNMEASURED. No snippets, no "rest unchanged".
Built one? Post it on X and tag @wikiwaynePost on X