InputLightweight
Device sensors
A phone’s tilt and shake as input.
A phone’s tilt and movement as input. Tilt to shift the layers of a scene, shake to reset. iPhones ask permission first, and desktops have to use the mouse in its place.
- Breaks when
- iOS needs an explicit permission request
- Also called
- DeviceOrientation, gyro, tilt, accelerometer
Prompts
Tilt parallax with a desktop stand-in
A layered scene whose depth layers shift by device tilt: request DeviceOrientationEvent.requestPermission on a tap (iOS), read beta and gamma, calibrate the resting angle at first read, clamp to ±25°, smooth with exponential damping, and map to ±40 px of parallax per depth unit. On desktop, use the pointer position with the same mapping. Show a small on-screen readout of the two angles.
Shake to shuffle
Detect a shake from DeviceMotionEvent acceleration (magnitude above 18 m/s² twice within 400 ms), debounced 1 s, to trigger a re-roll of a generative artwork. Provide the permission flow and a button fallback.
Compass-locked scene
Use absolute orientation (webkitCompassHeading on iOS, alpha with absolute: true elsewhere) to keep a 3D scene fixed in the real world as the phone turns, with the fallback to relative orientation when absolute is unavailable. Explain the coordinate frames and the 90° offset between portrait and landscape.
Related
Resources · 1
- MDN: DeviceOrientationEventmdnsite · codeApr 12, 2026