laserline

Neon line-riding WebXR game for Meta Quest 3 + Onewheel. Play: laserline.vercel.app

View on GitHub
JavaScript

Laserline

Neon line-riding for Meta Quest 3 + Onewheel. A color-shifting synthwave laser line draws itself across your real space in passthrough. Keep the board on it. Unbroken streaks raise the multiplier (x1 → x8) and the music builds layer by layer. Arches give bonus points, riding dead centre gives Perfect Line, and leaving the line muffles the music and breaks your streak.

x8 first person

It's a WebXR page (three.js, no build step, no audio files: every sound is synthesized live), so it runs in the Quest Browser.

Ride it

Hosted: open https://laserline.vercel.app in the Quest Browser. Redeploy after changes with vercel deploy --prod --yes --scope mileswiesenthals-projects.

Over USB (no hosting needed):

./quest.sh

This runs adb reverse and opens http://localhost:8080 in the Quest Browser. After that first load the service worker caches everything, so you can unplug, go outside, and open the same URL with no connection.

Or host it anywhere with HTTPS (Vercel, GitHub Pages, Netlify). It's static files, so deploy the folder as-is.

Your own courses (draw it, save it, ride it again)

  1. In the menu, tap Draw a new course (allow spatial data / anchors when the Quest asks).
  2. Hold pinch or trigger and point at the ground: a glowing pen with a tall pin follows where you point, up to 45 m (~150 ft) out. Walk or ride while you hold it and keep drawing, so a course can be as long as you like. Release to pause; press again and the line carries on from wherever the pen is.
  3. Grip / squeeze undoes the last stroke. Double-tap to save.
  4. What you draw is what you ride: no minimum corner radius, no reshaping. The pen filters your aim (left/right and up/down angles), so a hand tremor that would throw the spot metres toward or away from you at a grazing angle is steadied, while real sweeps aren't held back. Saving only takes out the last bit of jitter. On corners too sharp for a onewheel to carve, you'll swing wide; within 4 m of those corners being up to ~1 m off the line still counts as on it. The preview while drawing uses the same processing, so what you see is what gets saved. node test/fidelity.mjs and node test/smoothviz.mjs out.svg measure and draw this. If it ends within 4 m of where it started it becomes a lap course (lap times); otherwise it's start → finish against the clock (best time saved).
  5. Next time, pick it from Your courses and tap Ride. The game looks for the Quest spatial anchors it dropped at the start and every ~15 m, and puts the course back where you drew it. If it can't find them in ~8 s (or you squeeze), stand on the start, face along the course and pinch to line it up by hand.
  6. Ride to the green start ring and pinch. Leave the course and the game picks you up wherever you rejoin it.

Courses live in the Quest Browser's storage for this site (Rename / Delete in the menu). The anchors live on the headset.

drawing a course, then the saved course and its start ring

The generated line

In the headset: tap Ride in passthrough, then:

  1. Anywhere (default, for riding outside): face open space and pinch (allow spatial data when the Quest asks). The line keeps winding ahead of you for as long as you ride. It ignores your Quest boundary and instead steers round walls and objects the headset actually sees (see Walls below). In open space it meanders within about 60° of the direction you set off in, so it heads somewhere instead of circling; near walls it wanders between them. If you're facing a wall closer than ~4 m it won't start. Leave the line to go round something and after about 2 s a new line starts from where you are. If tracking jumps, you keep riding on a fresh line. Circle arena: stand at the edge of your empty space facing into it (or pick middle), point the board where you want to go, and pinch or pull the trigger. 3-2-1, then the line draws itself ahead of you. Trace arena: pinch, ride or walk the edge of your safe space all the way round, then pinch again to close it. The line stays at least 1.6 m inside whatever you traced.
  2. Ride the line. Hold pinch or trigger for about a second to end the run.

Quest boundary: Off (default). The game asks the headset for its unbounded space and never for local-floor, which is what triggers the stationary / room-scale boundary prompt and the fade-out when you leave it. If a headset refuses unbounded, it falls back to the plain local space and puts the floor 1.65 m below your head. Set Quest boundary: Use it in Setup to go back to the normal boundary. If the headset still shows a boundary on some firmware, you can turn it off in the headset's own settings (developer mode). Tracking is happiest at dusk or in shade with some visual texture around. Bright sun or a featureless lot can make it drift. If the headset re-centres, the game resets and asks you to set up again.

How it works

| Piece | File | |---|---| | Arena polygon, distance-field grid, path planner, rider tracker | src/path.js | | Wall map from depth + room scan, distance field, simulated worlds | src/obstacles.js, src/fieldworker.js | | Depth sensor GPU readback, room-scan planes and meshes | src/depth.js | | Drawn courses: smoothing, fixed-course planner, anchor alignment, storage | src/course.js | | Streaks, multiplier levels, gates, rerouting | src/game.js | | Laser ribbon + walls shader, arches, arena grid/fence, particles, shockwaves, text pops, HUD | src/visuals.js | | Procedural synthwave engine + SFX | src/audio.js | | Head pose → board position/heading; desktop rider + autopilot | src/rider.js | | XR session, game flow, event → effects wiring | src/main.js |

Path planner. Each metre it scores 45 two-stage curvature plans over a horizon long enough to see a full U-turn coming. A plan costs more if it gets near the arena edge, runs alongside the line that's still ahead of you (a clean figure-8 crossing is allowed), or strays from a slowly wandering "style" curvature, which is what makes it windy. Curvature changes are rate-limited (clothoid-like), so the line is always smooth and never tighter than the difficulty's turn radius (Chill 5 m, Flow 3.6 m, Carve 2.6 m, and tighter only when a small arena forces it, never below 2.2 m).

The line. The laser is a ~3 cm core with a tight bloom and a short blade standing on it so it reads from a distance. On-line tolerance is ±42 cm (Chill), ±30 cm (Flow), ±20 cm (Carve), marked by faint ticks either side.

Passthrough. The Quest composites the eye buffer over the cameras as premultiplied alpha. Every glow material uses GLOW blending in visuals.js (colour adds, alpha = glow brightness), so dim pixels stay see-through. Plain AdditiveBlending writes alpha 1 and paints the ground black. Preview the effect on desktop with ?autostart&autopilot&fakept.

Walls. src/obstacles.js keeps a 20 cm grid of what's solid around you, fed by:

  • the live depth sensor (src/depth.js, WebXR depth-sensing): ~10 times a second the depth texture is sampled down to 48×24 on the GPU, read back without stalling the frame, and turned into world points. Anything from knee to just over head height is a hit; every reading clears the floor between you and it, so people and cars that move away disappear. The sensor sees only ~5 m, so a wall first shows up as a short strip: each straight run of hits is assumed to carry on 3 m past what's visible until a ray shows otherwise.
  • the room scan (plane-detection, mesh-detection) when you're in a room set up in Space Setup: walls, furniture and the room mesh, all known up front.

A distance field over the grid (built in a worker, src/fieldworker.js) gives the planner clearance anywhere. Plans that come within 0.45 m of something solid are thrown out, and the line prefers ~1.7 m of room. When something new turns up on the line ahead, the line is cut 1 m in front of you and re-planned, swerving as tight as a onewheel carves (2.2 m radius) if it's close. Boxed in, it backs up the unridden part and turns for open space. A faint violet-to-red glow marks what it has detected, and the HUD says WALL! (with a warning tone) when you're within ~1.2 m.

Limits: nothing below ~30 cm (kerbs, potholes, steps down) counts, only what the depth camera has seen is avoided, and something wide that appears dead ahead at speed can still leave no room to dodge. You steer; the line helps.

Simulated check: npm test rides a walled car park and a street with a side turn and a dead end, seen only through a simulated 5 m, 100° depth sensor (and again with the walls known up front), 30 three-minute rides with no contact. node test/wallviz.mjs lot flow seen 90 out.svg draws one. On desktop, ?walls=lot or ?walls=street adds pretend walls seen through the same fake sensor.

Tracking. The board position is your head projected to the floor. Heading comes from your motion once you're rolling, and from where you're looking when you're nearly stopped. Wander more than 3.5 m from the line for about 2 s and it reroutes from where you are.

Music. Am–F–C–G at 108 BPM. x1 has pad and bass, x2 adds kick, x3 adds hats and arpeggio, x4 snare, x5 16th hats, x6 octave-up arp, x7 a supersaw lead. A master low-pass opens with every level and slams shut when you leave the line. Each gate plays the next note of a rising A-minor pentatonic run.

Develop / test

npm test # planner + game rules (4 arenas × 3 difficulties, walls) + drawn courses python3 -m http.server 8080 # then open http://localhost:8080

Useful URL flags:

  • ?autostart&autopilot&wobble=0.6: desktop preview that rides itself (wobble > 0 drifts off the line to show streak breaks)
  • &view=chase / &view=top: chase or top-down camera
  • ?emulate&autoride&timerraf: runs the real Quest code path under Meta's IWER Quest 3 emulator, with the emulated headset riding the line
  • &room=office_small (or office_large, living_room…): loads a scanned room from @iwer/sem (needs npm install) so the emulator has real depth, planes and a room mesh; &sense=depth / &sense=scan uses only one source
  • ?walls=lot|street: desktop preview with simulated walls
  • &nosw: skip the service worker

Desktop keys: W/S throttle, A/D carve, Space = pinch (hold to end), P autopilot, C chase cam, Esc menu.

vendor/ holds three.js 0.186.1 and IWER 2.7.0, copied from node_modules so the game works offline.

Safety

You're riding a powered board while seeing the world through cameras. Use an empty private space, wear a helmet and pads, start slow, and stop if the passthrough stutters or tracking drifts. The arena fence glows orange near the edge and the HUD shows EDGE! (or WALL! in Anywhere mode), but it's a guide, not a guarantee: the depth sensor reaches only a few metres and doesn't see kerbs or holes.

line bending away from a detected wall

License

MIT, see LICENSE. The bundled files in vendor/ are three.js and IWER, both under their own MIT licenses.

Created: November 20, 2026

Projects

Updated: November 20, 2026