Commit Graph

128 Commits

Author SHA1 Message Date
4ce5f5f2de updated scoreboard. 2025-12-01 10:54:09 -06:00
8180088b3b updated audio.
All checks were successful
Build / build (push) Successful in 1m56s
2025-12-01 08:55:21 -06:00
91e712edd9 Add level hints system for event-triggered audio playback
Some checks failed
Build / build (push) Has been cancelled
Implements a hint system that plays audio clips when specific game events occur:
- Ship status changes (fuel/hull/ammo thresholds)
- Asteroid destruction counts
- Ship collisions

Hints are stored in database with configurable play modes (once/always).
Also lowers background music volume from 0.5 to 0.2.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 08:45:20 -06:00
e3422ef9f2 Add mission brief audio playback using AudioEngineV2
All checks were successful
Build / build (push) Successful in 1m53s
- Add mission_brief_audio field to CloudLevelEntry interface
- Update missionBrief.ts to use AudioEngineV2.createSoundAsync()
  instead of legacy Sound class (fixes audio not playing)
- Pass audioEngine to MissionBrief.initialize() from Level1
- Add welcome_rookie.mp3 audio file

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 07:27:42 -06:00
c87b85de40 Fix ship physics init order and Supabase RLS user sync
All checks were successful
Build / build (push) Successful in 1m47s
- Pass initial position to ship.initialize() to set position BEFORE
  creating physics body, preventing collision race condition on reload
- Use get_or_create_user_id RPC (security definer) to bypass RLS
  for user profile sync in both authService and cloudLeaderboardService
- Sync user to Supabase on Auth0 login to ensure profile exists
- Add Supabase schema.sql and policies.sql for documentation

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 07:00:24 -06:00
d3d6175360 Fix mission brief trigger by using InputControlManager state
All checks were successful
Build / build (push) Successful in 1m45s
- Use InputControlManager.shipControlsEnabled instead of local flag
- Remove unused _controlsEnabled field from Ship class
- Fixes trigger press not dismissing mission brief screen

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-01 05:31:16 -06:00
5ce26c64ff Refactor weapon system to shape casting and parent status screen to ship
All checks were successful
Build / build (push) Successful in 1m47s
- Replace physics-based projectiles with shape cast collision detection
- Add ignoreBody to shape cast to prevent projectiles hitting ship mesh
- Parent StatusScreen to ship TransformNode instead of XR camera
- Add velocity check to victory condition (must be < 5 m/s)
- Adjust projectile spawn offset and velocity

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-30 16:03:27 -06:00
5cdbf22e67 Pre-position XR camera at cockpit before VR entry
All checks were successful
Build / build (push) Successful in 1m42s
Use setTransformationFromNonVRCamera to set XR reference space
to ship cockpit position before entering immersive mode. This
prevents camera jumping on Quest when the 2D preloader disappears.

Also includes:
- Ship physics tuning (reduced force multipliers and fuel consumption)
- Fix reverse thrust direction in shipPhysics.ts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 14:46:13 -06:00
226ec5f51a Fix bullet trajectory when ship is rotating
All checks were successful
Build / build (push) Successful in 1m48s
Calculate velocity at bullet spawn point (8.4 units from center) instead
of ship center. Accounts for tangential velocity from angular rotation
using cross product: velocity_at_spawn = linear + (angular × offset).

This fixes bullets appearing to drift when ship is moving and rotating.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 08:17:14 -06:00
b46f44e32d Performance fixes and debug features
All checks were successful
Build / build (push) Successful in 1m45s
- Fix duplicate render loops causing 50% FPS drop (70→40)
  - Add stopRenderLoop() before runRenderLoop() in level1.ts and levelSelectedHandler.ts
- Add ?loglevel=debug|info|warn|error query parameter
- Add Y button to toggle inspector in XR
- Throttle scoreboard updates to every 10 frames
- Throttle game-end condition checks to every 30 frames
- Remove per-frame logging from explosion animations
- Reduce background stars from 5000 to 2500
- Freeze asteroid material after loading
- Reduce physics substeps from 5 to 2
- Disable autoClear for Quest 2 performance

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 07:58:15 -06:00
cf3a74ff0b Fix scene doubling on reload and add dynamic inspector import
All checks were successful
Build / build (push) Successful in 1m45s
- Dispose old scene before creating new one (cleans up physics)
- Stop existing render loop before starting new one
- Dynamically import @babylonjs/inspector on 'i' key press

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 06:06:39 -06:00
dfa46c85a6 Hide canvas until XR camera positioned in ship cockpit
All checks were successful
Build / build (push) Successful in 1m0s
- Hide #gameCanvas by default in CSS (display: none)
- Show canvas in setupXRCamera() after camera is parented to ship
- Show canvas in flat mode fallback paths
- Fix preloader to append to document.body (was hidden with #levelSelect)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 05:42:53 -06:00
54d562d210 Fix XR camera initial height to match log message (0.8 → 1.2m)
🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 05:29:36 -06:00
123b341ed7 Replace debugLog and console.* with loglevel logger
- Create centralized logger module (src/core/logger.ts)
- Replace all debugLog() calls with log.debug()
- Replace console.log() with log.info()
- Replace console.warn() with log.warn()
- Replace console.error() with log.error()
- Delete deprecated src/core/debug.ts
- Configure log levels: debug for dev, warn for production
- Add localStorage override for production debugging

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 05:24:18 -06:00
e8ac3a8f0a Refactor main.ts to meet coding standards (<100 lines)
All checks were successful
Build / build (push) Successful in 1m7s
- Extract cleanup logic to src/core/cleanup.ts
- Extract XR setup to src/core/xrSetup.ts
- Extract scene/physics/audio setup to src/core/sceneSetup.ts
- Remove unused GameState enum and _gameState field
- main.ts reduced from 192 to 91 lines
- All methods now under 20 lines

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 05:01:28 -06:00
71ec1f162c Remove unused files and replay system
- Delete unused files: testLevel.ts, loginScreen.ts, controllerDebug.ts
- Remove entire replay system (ReplayManager, ReplayPlayer, ReplayCamera, etc.)
- Remove viewReplaysHandler.ts and discordWidget.ts
- Clean up related imports and references

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 04:54:54 -06:00
c0b9f772ee Refactor main.ts: extract handlers and remove dead code
- Extract analytics init to src/analytics/initAnalytics.ts
- Extract level selection handler to src/core/handlers/levelSelectedHandler.ts
- Extract replay handler to src/core/handlers/viewReplaysHandler.ts
- Extract app initialization to src/core/appInitializer.ts
- Remove unused DemoScene and demo.ts
- Remove dead code: DEBUG_CONTROLLERS, webGpu, TestLevel handler
- Add BabylonJS shader pre-bundling to fix Vite dev server issues
- Reduce main.ts from 885 lines to 211 lines

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 04:26:48 -06:00
5e67b796ba Add ESLint and refactor leaderboard to join with users table
- Add ESLint with typescript-eslint for unused code detection
- Fix 33 unused variable/import warnings across codebase
- Remove player_name from leaderboard insert (normalized design)
- Add ensureUserProfile() to upsert user display_name to users table
- Update leaderboard queries to join with users(display_name)
- Add getDisplayName() helper for leaderboard entries

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 03:52:03 -06:00
44c685ac2d Cleanup batch 5: Remove unused exported types
Made 75+ types internal (removed export keyword) across 24 files:
- Analytics event types (kept GameEventMap, GameEventName, GameEventProperties)
- Level config types (QuaternionArray, MaterialConfig, etc.)
- Ship types (SightConfig, InputState, etc.)
- Store state types (AuthState, GameConfigData, etc.)
- Various config interfaces

These types are still used internally but were never imported elsewhere.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 18:11:40 -06:00
e60280cf83 Cleanup batch 4: Remove 8 unused exports
- analytics/index.ts: Removed exports for AnalyticsService, NewRelicAdapter
- sphereLightmap.ts: Deleted createColoredSphereLightmap function
- scoreCalculator.ts: Made getTimeStars, getAccuracyStars, getFuelStars, getHullStars internal
- loginScreen.ts: Deleted showLoginScreen function

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 18:04:04 -06:00
bff8d2b33f Cleanup batch 3: Remove unused dependencies
Removed:
- openai (unused)
- svelte-preprocess (unused devDependency)

Kept: loglevel (still needed)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 17:43:54 -06:00
917cf7a120 Cleanup batch 2: Delete unused scripts
Removed scripts identified by knip as unused:
- scripts/generateDefaultLevels.cjs
- scripts/manageAdmin.ts
- scripts/runMigration.ts
- scripts/seedLevels.ts
- scripts/exportBlend.ts (had unresolved import)

Kept: seedLeaderboard.ts (still in use)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 17:42:55 -06:00
8570c22a0c Cleanup batch 1: Delete 11 unused source files
Removed files identified by knip as never imported:
- src/utils/scoreEvent.ts (duplicate type)
- src/components/shared/VectorInput.svelte
- src/levels/storage/ILevelStorageProvider.ts
- src/ship/shipEngine.ts
- src/levels/config/levelSerializer.ts
- src/levels/generation/levelEditor.ts
- src/levels/generation/levelGenerator.ts
- src/levels/stats/levelStats.ts
- src/ui/screens/controlsScreen.ts
- src/ui/screens/settingsScreen.ts
- src/environment/celestial/planetTextures.ts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 17:41:02 -06:00
b4baa2beba Migrate to cloud-only level system using Supabase
All checks were successful
Build / build (push) Successful in 1m44s
Remove all local level storage concepts and load levels exclusively from
Supabase cloud. Simplifies LevelRegistry from 380+ lines to ~50 lines.
Uses CloudLevelEntry directly throughout the codebase instead of wrapper
types like LevelDirectoryEntry.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 17:26:24 -06:00
c9d7b0f3a5 Update ship positions 2025-11-28 10:46:39 -06:00
a9ae41c7eb Fix WebXR camera setup and pointer selection timing
- Create consolidated setupXRCamera() method in Level1 to handle all XR
  camera initialization in one place
- Use intermediate TransformNode (xrCameraRig) for camera rotation since
  WebXR camera only uses rotationQuaternion which XR frame updates overwrite
- Fix pointer selection feature registration timing - must register after
  XR session starts, not during initialize()
- Move pointer registration to onStateChangedObservable and setupXRCamera()
- Don't stop render loop before entering XR as it may prevent observables
  from firing properly
- Fix audio paths in shipAudio.ts to use correct asset locations

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-28 10:22:59 -06:00
a9070a5d8f Add leaderboard infinite scroll and improve seed script scoring
All checks were successful
Build / build (push) Successful in 1m45s
- Add pagination support to CloudLeaderboardService with offset parameter
- Implement infinite scroll in Leaderboard.svelte using IntersectionObserver
- Update seed script to use actual game scoring formulas (time, accuracy, fuel, hull multipliers)
- Add level-specific asteroid counts and par times to seed data
- Create BUGS.md to track known issues
- Partial work on XR camera orientation (documented in BUGS.md)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 12:51:43 -06:00
e5607a564f Add leaderboard seed script with auto-migration
All checks were successful
Build / build (push) Successful in 1m43s
- Create scripts/seedLeaderboard.ts to populate fake leaderboard data
- Automatically creates is_test_data column if missing
- Add npm scripts: seed:leaderboard and seed:leaderboard:clean
- Add postgres and dotenv dev dependencies
- Configurable entry count (default 250)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 10:25:51 -06:00
a3e17c95db Add cloud leaderboard with Supabase integration
All checks were successful
Build / build (push) Successful in 1m39s
- Add Supabase service and cloud leaderboard service for score submission
- Fix Auth0 JWT by adding audience parameter for Supabase RLS compatibility
- Fix BabylonJS shader loading by adding @babylonjs/materials to Vite pre-bundle
- Update CI workflow with Supabase and Auth0 audience secrets

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-26 08:59:55 -06:00
0c03253c9a Add "Play on Quest" button to header for non-Quest browsers
All checks were successful
Build / build (push) Successful in 1m33s
Shows a button that uses Meta's Web Launch to send the current URL
to the user's Quest headset. Hidden when already browsing on Quest.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 19:00:18 -06:00
3ff1ffeb45 Simplify level system and add asteroid-mania level
All checks were successful
Build / build (push) Successful in 1m29s
- Add new asteroid-mania level to directory and DEFAULT_LEVEL_ORDER
- Remove level caching entirely (always fetch fresh from network)
- Delete legacy router.ts, levelSelector.ts, and levelVersionManager.ts
- Remove unused router handlers from main.ts (~120 lines)
- Fix projectile curving by cloning velocity vector in weaponSystem.ts
- Update LevelSelect.svelte to include asteroid-mania

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 15:34:23 -06:00
3a5cf3e074 add secrets for auth0
All checks were successful
Build / build (push) Successful in 1m30s
2025-11-25 13:27:30 -06:00
3f164df9e8 Add game results leaderboard system
All checks were successful
Build / build (push) Successful in 1m30s
- Create GameResultsService for storing game results in localStorage
- Create gameResultsStore Svelte store for reactive data access
- Add Leaderboard component showing top 20 scores
- Add leaderboard route and navigation link
- Record game results on victory/death/stranded (not manual exits)
- Fix header visibility when exiting game
- Fix camera error by stopping render loop after cleanup
- Clear canvas after cleanup to prevent last frame showing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 12:39:23 -06:00
28c1b2b2aa Fix routing, cleanup, and game restart issues
- Switch from svelte-spa-router to svelte-routing for clean URLs without hashes
- Fix relative asset paths to absolute paths (prevents 404s on nested routes)
- Fix physics engine disposal using scene.disablePhysicsEngine()
- Fix Ship observer cleanup to prevent stale callbacks after level disposal
- Add _gameplayStarted flag to prevent false game-end triggers during init
- Add hasAsteroidsToDestroy check to prevent false victory on restart
- Add RockFactory.reset() to properly reinitialize asteroid mesh between games
- Add null safety checks throughout RockFactory for static properties

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 11:21:05 -06:00
622e0a5259 Fix VR pointer interaction with GUI by removing restrictive picking predicate
All checks were successful
Build / build (push) Successful in 1m34s
Resolved issue where VR laser pointers could not click mission brief buttons. Root cause was scene.pointerMovePredicate filtering out GUI meshes before pointer events could reach AdvancedDynamicTexture.

Changes:
- Commented out restrictive pointerMovePredicate that blocked GUI mesh picking
- Temporarily disabled renderingGroupId=3 on mission brief for VR compatibility
- Adjusted ship physics: reduced angular force multiplier (1.5→0.5) and increased damping (0.5→0.6)

Technical details:
- WebXRControllerPointerSelection uses scene.pointerMovePredicate during pickWithRay()
- If predicate returns false, pickInfo.hit=false and GUI events never fire
- AdvancedDynamicTexture requires pickInfo.pickedMesh === mesh to process events
- Removing predicate allows default behavior (all isPickable meshes are candidates)

TODO: Re-implement predicate using renderingGroupId === 3 check for production

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-24 17:53:31 -06:00
fa15fce4ef Fixed some physics problems. 2025-11-24 17:03:41 -06:00
e31e25f9e5 Fix physics issues: sleep behavior, center of mass, and input scaling
This commit resolves several physics-related issues that were causing
unexpected behavior in ship and asteroid movement:

**Physics Sleep System**
- Fixed abrupt stops by preventing Havok from putting bodies to sleep
- Added PhysicsActivationControl.ALWAYS_ACTIVE for ship and asteroids
- Made ship sleep behavior configurable via shipPhysics.alwaysActive
- Sleep was causing sudden velocity zeroing at low speeds

**Center of Mass Issues**
- Discovered mesh-based physics calculated offset CoM: (0, -0.38, 0.37)
- Override ship center of mass to (0, 0, 0) to prevent thrust torque
- Applying force at offset CoM was creating unwanted pitch rotation
- Added debug logging to track mass properties

**Input Deadzone Improvements**
- Implemented smooth deadzone scaling (0.1-0.15 range)
- Replaced hard threshold cliff with linear interpolation
- Prevents abrupt control cutoff during gentle inputs
- Added VR mode check to disable keyboard fallback in VR

**Configuration System**
- Added DEFAULT_SHIP_PHYSICS constant as single source of truth
- Added tunable parameters: linearDamping, angularDamping, alwaysActive
- Added fuel consumption rates: linearFuelConsumptionRate, angularFuelConsumptionRate
- Tuned for 1 minute linear thrust, 2 minutes angular thrust at 60Hz
- All physics parameters now persist to localStorage

**Other Fixes**
- Changed orbit center to STATIC motion type (was ANIMATED)
- Fixed linear force application point (removed offset)
- Added ship initial velocity support from level config
- Changed physics update from every 10 frames to every physics tick
- Increased linear input threshold from 0.1 to 0.15

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-24 14:03:32 -06:00
71ff46e4cf Implement comprehensive scoring system with star ratings
All checks were successful
Build / build (push) Successful in 1m35s
Add linear-clamped scoring system that rewards speed, accuracy, fuel
efficiency, and hull integrity. Scores are always positive with a 0.5x
multiplier floor for refueling/repairs.

Scoring Components:
- Create scoreCalculator module with configurable scoring logic
- Time multiplier: Exponential decay from par time (0.1x to 3.0x)
- Accuracy multiplier: Linear 1.0x to 2.0x based on hit percentage
- Fuel efficiency: Linear with 0.5x floor (handles refueling >100%)
- Hull integrity: Linear with 0.5x floor (handles deaths/repairs >100%)
- Star rating system: 0-3 stars per category (12 stars max)

Integration:
- Add calculateFinalScore() to GameStats
- Support parTime in level config metadata
- Auto-calculate par time from difficulty level in Level1
  - Recruit: 300s, Pilot: 180s, Captain: 120s, Commander: 90s, Test: 60s
- Display comprehensive score breakdown on status screen

Status Screen Updates:
- Increase mesh size from 1.5x1.0m to 1.5x2.25m (portrait orientation)
- Increase texture from 1024x768 to 1024x1536 (fit all content)
- Add score display section with:
  - Final score in gold with thousand separators
  - Score multiplier breakdown for each category
  - Unicode star ratings (★★★) per category
  - Total stars earned (X/12)

Formula:
finalScore = 10,000 × time × accuracy × fuel × hull

All multipliers ≥ 0.5, ensuring scores are never negative even with
multiple refuels/deaths. System rewards balanced excellence across all
performance metrics.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-22 06:32:55 -06:00
1422c5b926 Add centralized input control management and mission brief improvements
All checks were successful
Build / build (push) Successful in 1m31s
- Create InputControlManager singleton for centralized ship controls and pointer selection management
  - Last-wins behavior for state changes
  - Mutually exclusive ship controls and VR pointer selection
  - Observable events for state changes with requester tracking
  - Enables debugging and prevents conflicts between UI components

- Refactor Ship class to use InputControlManager
  - Remove disableControls() and enableControls() methods
  - Register input systems with InputControlManager on initialization
  - Simplify control state management throughout ship lifecycle

- Update StatusScreen to use InputControlManager
  - Remove manual pointer selection enable/disable methods
  - Delegate control management to InputControlManager
  - Automatic laser pointer enabling when screen shows

- Update Level1 mission brief to use InputControlManager
  - Consistent control management for mission brief display
  - Proper pointer selection during mission brief interaction

- Fix controller input trigger blocking bug
  - Triggers now properly blocked when controls disabled
  - Prevents shooting when status screen or mission brief is visible
  - Only X-button (status screen toggle) allowed when disabled

- Add START MISSION button to mission brief
  - Replace "Pull trigger to start" text with clickable button
  - Green styled button matching StatusScreen design
  - Works with VR laser pointer interaction
  - Trigger pull still works as fallback

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 17:25:11 -06:00
eccf101b73 Implement Svelte-based UI architecture with component system
All checks were successful
Build / build (push) Successful in 1m20s
Major refactoring of the UI layer to use Svelte components:
- Replace inline HTML with modular Svelte components
- Add authentication system with UserProfile component
- Implement navigation store for view management
- Create comprehensive settings and controls screens
- Add level editor with JSON validation
- Implement progression tracking system
- Update level configurations and base station model

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 15:01:17 -06:00
ff8d69b6ec Add VR controller remapping configuration system
All checks were successful
Build / build (push) Successful in 1m32s
Implement comprehensive controller remapping UI that allows users to customize
VR controller button and stick mappings with per-axis granularity and inversion
controls. Configuration persists to localStorage and applies on level start.

## Features
- Full-page controller remapping UI at #/controls
- Per-axis stick mapping (4 dropdowns: leftX, leftY, rightX, rightY)
- Individual axis inversion toggles (8 total invert options)
- Button remapping (6 buttons: trigger, A, B, X, Y, squeeze)
- Available actions: yaw, pitch, roll, forward thrust, camera, status screen
- Configuration validation with warnings for duplicates/missing controls
- Preview/test functionality to review current mapping
- Reset to default option
- localStorage persistence with backward compatibility

## Implementation
- ControllerMappingConfig singleton manages configuration and validation
- ControlsScreen handles UI logic and form manipulation
- ControllerInput applies mapping by translating raw input to actions
- Actions mapped back to virtual stick positions for ShipPhysics
- No changes needed to ShipPhysics - receives correctly mapped values

## User Flow
1. Navigate to Controls via header menu
2. Select action for each stick axis (yaw/pitch/roll/forward/none)
3. Toggle invert checkboxes as needed
4. Assign button actions (fire/camera/status/none)
5. Save configuration
6. Changes apply when starting new level

## Technical Details
- Storage key: 'space-game-controller-mapping'
- Raw stick values stored, mapping applied in getInputState()
- Supports future actions without code changes
- Validation ensures critical controls (fire, forward) are mapped

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 08:11:04 -06:00
e9ddf91b85 Implement trigger-based mission brief dismissal for VR gameplay
All checks were successful
Build / build (push) Successful in 1m33s
Add mission briefing system that displays when entering VR and requires
trigger pull to dismiss before gameplay begins. This prevents accidental
weapon firing and provides clear mission objectives to players.

## Key Features
- Mission brief displays on VR entry with objectives from directory.json
- Ship controls disabled during briefing (movement, rotation, weapons)
- Either controller trigger dismisses brief and starts game timer
- First trigger pull does not fire weapons, only dismisses briefing
- Subsequent trigger pulls fire weapons normally

## Implementation Details
- Added MissionBrief class with mesh-based UI parented to ship
- Ship class gains disableControls()/enableControls() methods
- New mission brief trigger observable bypasses normal shoot handling
- ControllerInput modified to allow triggers through when disabled
- Level1 orchestrates control flow: disable → show brief → enable
- Game timer and physics recording start only after dismissal

## Technical Changes
- controllerInput.ts: Allow trigger events when controls disabled
- ship.ts: Add control state tracking and mission brief observable
- level1.ts: Integrate mission brief into XR initialization flow
- missionBrief.ts: New class for displaying briefing with trigger detection
- Fixed property name mismatch in level selection event dispatch
- Added cache-busting for dev mode level loading
- Exposed LevelRegistry to window for debugging

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-21 07:44:46 -06:00
fd1a92f7e3 Add analytics abstraction layer with intelligent batching
All checks were successful
Build / build (push) Successful in 2m0s
Implements a flexible, provider-agnostic analytics system with New Relic adapter featuring intelligent event batching for cost optimization.

Features:
- Type-safe event tracking with TypeScript interfaces
- Pluggable adapter architecture for multiple providers
- Intelligent batching (reduces data usage by 70-90%)
- Event sampling for high-volume events
- Zero breaking changes to existing New Relic setup
- Debug mode for development testing

Integration points:
- Session tracking in main.ts
- Level start and WebXR events in level1.ts
- Asteroid destruction and hull damage in ship.ts
- Performance snapshots and session end in gameStats.ts

Events tracked:
- session_start, session_end
- webxr_session_start
- level_start
- asteroid_destroyed (20% sampled)
- hull_damage
- gameplay_snapshot (60s intervals, 50% sampled)

Cost optimization:
- Batching reduces individual events by ~70%
- Sampling reduces high-frequency events by 50-80%
- Combined savings: ~90% data reduction
- Keeps usage safely under New Relic free tier (100GB/month)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-12 16:22:28 -06:00
7e5f7ef1e5 Add New Relic browser monitoring and update base station model
All checks were successful
Build / build (push) Successful in 1m33s
- Integrate New Relic browser agent for performance monitoring and analytics
- Configure distributed tracing, performance metrics, and AJAX monitoring
- Update base.glb model file with latest changes
- Add baked texture for default theme

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-12 11:11:00 -06:00
244a25fff5 Implement hybrid level storage system with JSON-based defaults and configurable orbit constraints
All checks were successful
Build / build (push) Successful in 1m34s
Major changes:
- Add LevelRegistry for managing default (JSON) and custom (localStorage) levels
- Default levels now load from /public/levels/*.json files
- Add 6 default level JSON files (rookie-training through final-challenge)
- Implement version-based automatic cache invalidation
- Add LevelVersionManager for tracking level updates
- Add LevelStatsManager for performance tracking (completion rate, best time, etc.)
- Add legacy migration tool for existing localStorage data
- Update level selector UI with stats display and version badges
- Add configurable orbit constraints per level (useOrbitConstraints flag)
- Hide copy button in level selector UI (TODO: re-enable later)
- Add extensive debug logging for velocity troubleshooting
- Add cloud sync infrastructure interfaces (future-ready)

Technical improvements:
- Hybrid storage: immutable defaults from JSON, editable custom levels in localStorage
- Automatic cache refresh when directory.json version changes
- Cache API for offline support
- Fresh start migration approach with export option
- Level loading now initializes before router starts

Physics configuration:
- Add useOrbitConstraints flag to LevelConfig
- Rookietraining.json uses constraints (velocities will create orbital motion)
- Debug logging added to verify velocity application

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-11 18:40:01 -06:00
500830779d Add level configuration system and update base station model
All checks were successful
Build / build (push) Successful in 1m26s
- Add level 1 JSON with 4 asteroids and difficulty config
- Add mission directory with recruit and fuel management missions
- Update base.glb model for space station
- Clean up unused helper functions in planetTextures.ts
- Refactor starBase.ts position handling to use container root node

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-11 17:26:18 -06:00
8275c53fe4 Re-enable Discord widget with enhanced error logging for GraphQL debugging
All checks were successful
Build / build (push) Successful in 1m31s
Previously disabled due to GraphQL errors. Now re-enabled with comprehensive
error logging to diagnose the specific issue.

Changes to discordWidget.ts:
- Wrapped initialization in try-catch with detailed error logging
- Added step-by-step console logs through initialization process
- Added error event listener on the widget
- Added window.onerror handler to catch widgetbot/GraphQL errors

Changes to main.ts:
- Uncommented Discord widget initialization
- Added detailed error logging in catch block
- Log error type, message, stack, and GraphQL response if available

Next steps:
- Load the application in browser
- Check console for detailed error messages
- Identify specific GraphQL query/mutation causing issues
- Server ID: 1112846185913401475
- Channel ID: 1437561367908581406

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-11 17:18:50 -06:00
9b22b06d08 Fix critical bug: Repeating voice messages now stop when resources recover
All checks were successful
Build / build (push) Successful in 1m24s
Added stateKey field to VoiceMessage interface to explicitly link messages
with warning states, preventing infinite repeat loops.

Bug fixes:
- Messages check warning state exists before re-queuing
- clearWarningState() now purges matching messages from queue
- Proper cleanup when resources increase above thresholds

Changes to voiceAudioSystem.ts:
- VoiceMessage interface: Added stateKey field
- queueMessage(): Added stateKey parameter
- handleStatusChange(): Pass state keys when queueing warnings
- update(): Validate state exists before re-queuing repeating messages
- clearWarningState(): Filter queue to remove messages with matching stateKey

Also includes explosion audio improvements:
- Use onEndedObservable instead of setTimeout for audio cleanup
- Adjusted explosion force and duration parameters

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-11 16:57:12 -06:00
b523d5e31a Add repeating voice announcements with danger/warning prioritization
Implemented repeating voice messages that automatically replay at intervals until the condition clears, with danger messages superseding warnings.

Changes:
- VoiceMessage interface: Added repeatInterval and lastPlayedTime fields
- queueMessage(): Now accepts repeatInterval parameter (0 = no repeat)
- update(): Implements repeat logic
  - After sequence completes, checks repeatInterval
  - Re-queues message with timestamp tracking
  - Waits for interval to elapse before replaying
- clearWarningState(): New method to clear specific warning states
- handleStatusChange(): Enhanced logic with prioritization
  - Clears warning states when resources increase above thresholds
  - Danger warnings (< 10%): repeat every 2s, clear warning state
  - Regular warnings (10-30%): repeat every 4s, only if not in danger
  - Empty warnings: play once, no repeat

Behavior:
- Fuel 25%: "warning → fuel" repeats every 4s
- Fuel drops to 8%: Warning stops, "danger → fuel" repeats every 2s
- Fuel recovers to 15%: Danger stops, "warning → fuel" resumes
- Fuel recovers to 35%: All warnings stop
- Refueling/repairing clears states, allows re-triggering

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-11 16:24:28 -06:00
415496b3a2 Add voice audio system for cockpit computer announcements
All checks were successful
Build / build (push) Successful in 1m21s
Implemented VoiceAudioSystem class that loads voice clips and plays them sequentially in response to game events (fuel/hull/ammo warnings).

Changes:
- VoiceAudioSystem: New class for managing voice audio
  - Loads 13 voice MP3 files (warning, danger, fuel, hull, ammo, etc.)
  - Priority queue system (HIGH, NORMAL, LOW)
  - Sequential playback with state polling
  - One-shot warning tracking to prevent spam
  - Non-spatial audio (cockpit computer voice)

- Ship: Integrated VoiceAudioSystem
  - Initialize voice system after ShipAudio
  - Subscribe to ShipStatus.onStatusChanged events
  - Call update() in render loop for sequential playback

Features:
- Event-driven warnings trigger on status thresholds
  - Fuel/hull/ammo < 30%: "warning" → resource name
  - Fuel/hull/ammo < 10%: "danger" → resource name
  - Resource = 0: resource name → "empty"
- Comprehensive debug logging for troubleshooting
- State machine handles queue and playback sequencing

Note: Current implementation has a bug in getMaxValue() calculation that prevents warnings from triggering correctly. Will be fixed in next commit.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-11 15:18:41 -06:00