# 🎮 Complete Controls Reference

Last Updated: October 24, 2025

## 📋 Table of Contents
- [Desktop Controls](#desktop-controls)
- [Mobile Controls](#mobile-controls)
- [3D Model Controls](#3d-model-controls)
- [SSR Master Control Panel](#ssr-master-control-panel)
- [Keyboard Shortcuts](#keyboard-shortcuts)

---

## 🖥️ Desktop Controls

### Camera Navigation
- **Left Click + Drag**: Rotate camera around model
- **Right Click + Drag**: Pan camera
- **Mouse Wheel**: Zoom in/out
- **Middle Mouse + Drag**: Pan camera (alternative)

### FPS-Style Camera (WASD)
- **W**: Move forward
- **S**: Move backward
- **A**: Strafe left
- **D**: Strafe right
- **Q**: Move down
- **E**: Move up
- **Shift + Movement**: Speed boost (3x faster)

### Quick Actions
- **F**: Frame camera to fit model
- **R**: Reset camera to default position
- **Double-Click Model**: Frame to fit
- **Double-Click Empty Space**: Reset view

---

## 📱 Mobile Controls

### Touch Gestures
- **One Finger Drag**: Rotate camera
- **Two Finger Drag**: Pan camera
- **Pinch**: Zoom in/out
- **Double Tap Model**: Frame to fit
- **Double Tap Empty**: Reset view

### Virtual Joystick (Mobile Fullscreen)
- **Joystick**: Move camera (FPS-style)
- **Drag Joystick**: Control movement direction
- **Distance from Center**: Control movement speed

---

## 🎨 3D Model Controls

Located at the bottom of the viewer in model gallery mode.

### Row 1: Animation & Camera
- **Animation Select**: Choose model animation
- **▶️ Play**: Play/stop animation
- **🔄 Auto**: Toggle auto-rotation
- **📷 Fit**: Frame camera to model

### Row 2: Material Colors
- **🔴 Red**: Apply red material
- **🔵 Blue**: Apply blue material
- **🟢 Green**: Apply green material
- **🎨 Reset**: Reset to original material

### Row 3: Transform Gizmo
- **🎛️ Gizmo**: Toggle transform gizmo on/off
- **↔️ Move**: Enable move mode
- **🔄 Rotate**: Enable rotate mode
- **📏 Scale**: Enable scale mode

### Row 4: Lighting & Environment
- **HDRI**: Toggle HDRI background on/off
- **🌟**: Cycle through HDRI environments
- **💡**: Cycle lighting modes (Directional/Point/Spot)
- **🏔️ Floor**: Toggle ground plane
- **☀️ Light**: Cycle light direction

---

## 🎛️ SSR Master Control Panel

Located at top-right corner in model gallery mode. Compact, discrete panel with cyberpunk aesthetic.

### Panel Header
- **🎨 Controls**: Panel title
- **▼/▲**: Expand/collapse panel

### Categories

#### 🎯 Post-Processing
- **FXAA Toggle**: Anti-aliasing on/off
  - Quality Slider: 0.1 - 1.0
- **Fog Toggle**: Atmospheric fog on/off
  - Density Slider: 0.001 - 0.1
  - Distance Slider: 10 - 100

#### 🌟 Screen Space Reflections (SSR)
- **SSR Toggle**: Enable/disable SSR
  - Intensity Slider: 0 - 1
  - Max Distance Slider: 1 - 10
  - Thickness Slider: 0.01 - 1

#### 🎨 Color Grading
- **Brightness Slider**: -1 to 1
- **Contrast Slider**: 0 to 2
- **Saturation Slider**: 0 to 2

#### ✨ Bloom Effect
- **Bloom Toggle**: Glow effect on/off
  - Strength Slider: 0 - 3
  - Radius Slider: 0 - 1
  - Threshold Slider: 0 - 1

---

## ⌨️ Keyboard Shortcuts

### Gallery Navigation
- **Arrow Left**: Previous item
- **Arrow Right**: Next item
- **Escape**: Exit fullscreen

### Video Controls (Video Gallery)
- **Spacebar**: Play/pause video

### Camera Controls (Model Gallery)
- **W/A/S/D**: FPS camera movement
- **Q/E**: Vertical movement
- **Shift**: Speed boost
- **F**: Frame model
- **R**: Reset camera

---

## 🎯 Control Behavior

### Visibility Rules
- **Model Gallery**: All controls visible
- **Image Gallery**: Only navigation controls
- **Video Gallery**: Only navigation and video controls

### Fullscreen Mode

**⚠️ CRITICAL: Image gallery zoom, pan, and double-click work in fullscreen mode.**

#### Image Gallery Fullscreen Controls
- **Double-click**: Toggle between fit and zoomed states (works in fullscreen)
- **Mouse wheel**: Zoom in/out (works in fullscreen)
- **Left-click drag**: Pan when zoomed in (works in fullscreen)
- **Arrow keys**: Navigate between images (works in fullscreen)
- **ESC**: Exit fullscreen

#### Implementation Details
- Event listeners are attached to `#image-gallery` and `.showcase-viewer` elements inside fullscreen
- Double-click is attached to multiple elements (gallery, viewer, image, item) for reliability
- Pointer events are enabled via CSS in fullscreen mode
- Text selection is disabled to prevent blue highlight on double-click
- Event listeners are NOT attached to the fullscreen element itself to avoid blocking navigation

#### Desktop Fullscreen
- All controls maintain position
- **Mobile**: Controls adapt to fullscreen layout
- **SSR Panel**: Always top-right, below header

### Responsive Design
- **Desktop**: Full-size buttons (70x20px)
- **Mobile**: Larger touch targets (70x32px)
- **Animation Select**: Wider for readability (120x20px desktop, 100x32px mobile)

---

## 🔧 Technical Notes

### Control Styling
- **Compact Design**: Minimal padding and gaps
- **Font Sizes**: 9-11px for discrete appearance
- **Z-Index Hierarchy**:
  - SSR Panel: 999999999 (all modes when open)
  - Showcase Viewer: 10000 (when panel open)
  - Showcase Header: 10000
  - Model Controls: 10000
  - Gallery Arrows: 900 (below viewer, hidden when panel open)
  - Canvas: 1

### Gallery Arrow Behavior
- **When Controls Panel Opens**: Both navigation arrows (`.prev` and `.next`) automatically hide in all modes:
  - Portrait non-fullscreen
  - Portrait fullscreen (mobile)
  - Landscape non-fullscreen
  - Landscape fullscreen (mobile)
  - Desktop fullscreen
- **Hiding Properties**: `opacity: 0`, `visibility: hidden`, `pointer-events: none`
- **Z-Index**: Arrows set to `900` (below viewer at `10000`) so panel can draw over them
- **Consistent Behavior**: Same z-index hierarchy and hiding behavior across all modes

### Controls Panel Overlay Behavior
- **⚠️ STATUS**: Needs verification - Controls panel should draw over arrows in ALL modes
- **Panel Z-Index**: `999999999` (above everything) when panel-open in most modes:
  - Portrait non-fullscreen: ✓ Has rule (line 990)
  - Portrait fullscreen (mobile): ✓ Has rule (lines 1016-1019)
  - Landscape non-fullscreen: ✓ Has rule (line 3468)
  - Landscape fullscreen (mobile): ✓ Uses mobile fullscreen rule
  - Desktop fullscreen: ⚠️ Has rule but not panel-open specific (line 4778)
- **Z-Index Hierarchy** (when panel open):
  - Controls Panel: `999999999` (top layer)
  - Showcase Viewer: `10000` (middle layer) - ⚠️ Missing for desktop fullscreen
  - Gallery Arrows: `900` (bottom layer, hidden)
- **Known Issues**:
  - Desktop fullscreen viewer z-index rule missing when panel-open
  - Multiple duplicate rules for mobile fullscreen (may cause conflicts)
  - Desktop fullscreen panel z-index applies to all active galleries, not just when panel-open
- **See**: `docs/Z_INDEX_AUDIT.md` for complete audit report

### Performance
- Controls pause when not visible
- Animations stop when switching galleries
- Effects disable automatically on low-end devices

---

## 📝 Adding New Controls

### Model Controls (Bottom Bar)
Edit `index.html` in the `threejs-controls` section:
```html
<div class="controls-row">
    <button id="my-button" class="control-btn" title="My Action">🎯 Label</button>
</div>
```

### SSR Panel (Top-Right)
Edit `index.html` in the `master-control-panel` section:
```html
<div class="control-group">
    <button id="my-effect-toggle" class="effect-toggle-btn">My Effect</button>
    <div class="slider-group">
        <label for="my-slider">Intensity</label>
        <input type="range" id="my-slider" class="effect-slider" 
               min="0" max="1" step="0.1" value="0.5">
    </div>
</div>
```

### Styling
All control styles are in `style.css`:
- Model controls: Search for `.threejs-controls`
- SSR panel: Search for `.master-control-panel`
- Mobile: Search for `@media (max-width: 768px)`

---

## 🐛 Troubleshooting

### Controls Not Visible
- Check if correct gallery is active (model gallery for 3D controls)
- Verify fullscreen mode is working
- Check browser console for errors

### Controls Not Responding
- Ensure model is loaded
- Check if controls are enabled in settings
- Verify no modal is blocking interaction

### Mobile Controls Issues
- Ensure touch events are enabled
- Check virtual joystick positioning
- Verify mobile-fullscreen class is applied

---

## 📚 Related Documentation
- [Project Summary](PROJECT_SUMMARY.md)
- [Folder Structure](FOLDER_STRUCTURE.md)
- [Quick Reference](QUICK_REFERENCE.md)

---

<p align="center">
  <strong>Built with Three.js</strong><br>
  <sub>Intuitive controls for immersive 3D experiences</sub>
</p>
