jimhasadhd.fyi
No. 18
All issues

A ghost in the fold

Fold the new folding iPhone like a laptop and the camera follows your head, so both screens become windows into a little 3D world. Stand a triangle of clear plastic on the bottom screen and a ghost floats in the air in front of the upright one. Open source, so you can build your own.

What hooked me

A folding iPhone turned up, and half open it's a tiny laptop: one screen standing up, one lying flat. That's exactly the shape of a Pepper's ghost, the Victorian stage trick where a sheet of glass at 45° reflects a hidden image so a ghost seems to stand on stage. The flat half is the hidden image. The upright half is the stage.

What I built

DuoGhost, a web app for the iPhone Duo folded at about 90°, with two modes. Try it at duoghost.jimhasadhd.fyi; the code is on GitHub at unit92/duoghost.

  • Window mode needs nothing else. It's the old-school head-tracking trick: the front camera finds your eyes and every frame is drawn from exactly where you are. The upright screen looks back into a grid room, the flat screen looks down into a pit beneath it, and bullseye targets on sticks rise up through the flat screen into the air between the two. Move your head and you look round them. It works on a laptop webcam too.
  • Hologram mode needs a triangle of clear plastic. The bottom screen draws the ghost upside down, the plastic reflects it, and it floats a couple of centimetres in front of the upright screen, at a real depth your two eyes agree on. The upright screen is a dim backdrop behind it.
  • Three ghosts: Wisp, who watches you, hides when you look away and says BOO when you come back; Specimen, a knot spinning on a projector base; and You, the camera feed with the background cut out.
  • It reads where the fold is from Safari 27.1's brand-new Device Posture and Viewport Segments APIs, which are still behind feature flags, and falls back to the middle of the screen.
  • It's open source. Underneath is a small three.js library for anyone who wants to play with head-tracked 3D on folding phones: fold detection, the phone modelled in millimetres, a projection that turns each screen into a window, and camera head tracking. There are two short examples to start from. Code and docs on GitHub.

What I learned

  • A web page can now find out where the fold is, but not the hinge angle. That's still native-only.
  • Each screen needs its own skewed camera, aimed through its own rectangle from your eye. Do that and one object can sit across the fold, half drawn on each screen, and still look whole.
  • Only the plastic's angle to the bottom screen matters. The hinge can be anywhere near 90°.
  • In a reflection, black is invisible. So the ghost's eyes aren't drawn on: they're holes you see the backdrop through.

#hologram#iphone#webgl#camera#open source