# RCWeb 3D Viewer Control App

The **RCWeb 3D Viewer Control App** (`app/3dviewer-c`) serves as a precision gyroscopic presenter remote for the 3D Viewer application inside the **Asymmetric Pattern**. 

![icon](pwa-512x512.png "3D Viewer Control App Icon")

## Screenshot
![screenshot](screenshot.png "3D Viewer Control App")

## What it does

- **Absolute Hardware Mirroring**: Reads raw 6-axis gyroscopic accelerometer data natively converting precise hand inclination into flawless 1:1 remote rotation commands.
- **Takeover Notification**: Implements complex multiple-device handshaking. If two phones scan the viewer screen consecutively, the viewer will accept the newest device and transmit a forced eviction payload to the old remote, rendering an "Another controller took over" toast notification.
- **Orientation Normalization**: Tracks device screen adjustments actively locking native `window.screen.orientation` and applying an inverted multiplier ensuring the model doesn't wildly snap upside-down when the phone naturally tilts sideways in the user's hand.

## How it works

The script heavily offloads mathematical calculations from the primary viewer natively into the client device.

- **Euler to Quaternion Math**: Rather than forcing the main host server to compute orientation translations, the controller manually unpacks the raw `DeviceOrientationEvent` variables (`alpha`, `beta`, `gamma`) into deep trigonometric functions natively inside Javascript utilizing heavily optimized `quaternionFromEuler` and `quaternionFromAxisAngle` matrix generators.
- **Delta Threshold Bandwidth Caps**: The loop employs a strict `ORIENTATION_EPSILON` variable comparing mathematical differentials between the `lastOrientationPayload` and the current orientation. If the phone is merely resting idly on a desk, literally zero network packets are needlessly transmitted.
- **Fallback Polling**: If the host is utilizing a VPN router rendering device sensors blocked entirely, the code gracefully strips the complex quaternion math and binds raw hardcoded degree nudges (`sendNudge(x, y, z)`) to on-screen DOM buttons.
