How andymutale/rosegold-xr works
Rosegold XR is a browser-based 3D Pac-Man prototype with mobile controls and experimental room-scale AR. The runtime starts in src/main.ts: it creates the game and Three.js scene, connects keyboard/swipe input, and drives rendering and HUD updates. In AR, it scans room geometry, optionally generates a maze sized to a detected floor, and places the board using hit-test or floor-fitting data. The graph preserves the major gameplay, rendering, validation, and XR modules listed in the source index. Some runtime-loop details are unsampled; those relationships are omitted rather than inferred.
Main entry points: main.ts Runtime coordinator · game.ts Game controller · hud.ts Game HUD · keyboardInput.ts Keyboard controls
Components 22
Runtime orchestration
- Runtime coordinator
src/main.ts
Game rules
- Game controller
src/game/game.ts - Maze parsing
src/game/maze.ts - Player movement
src/game/movement.ts - Ghost movement
src/game/ghostMovement.ts - Pellet scoring
src/game/pellets.ts - Room maze generation
src/game/generateRoomMaze.ts - Game data types
src/game/types.ts
Controls and display
- Keyboard controls
src/input/keyboardInput.ts - Swipe controls
src/input/swipeInput.ts - Three.js scene
src/render/scene.ts - Maze board renderer
src/render/boardRenderer.ts - Character renderer
src/render/characterRenderer.ts - World coordinates
src/render/coordinates.ts - Placement marker
src/render/placementMarker.ts - Game HUD
src/ui/hud.ts - State validation
src/validation/schemas.ts
Room-scale XR
- AR session adapter
src/xr/arSession.ts - Surface hit testing
src/xr/hitTest.ts - Room understanding
src/xr/roomUnderstanding.ts
Other components
- Player
- Browser XR
Connections 25
- Player → Keyboard controls: presses keys
- Player → Swipe controls: swipes screen
- Keyboard controls → Game controller: requests direction
src/main.ts - Swipe controls → Game controller: requests direction
src/main.ts - Runtime coordinator → Game controller: creates and steps
src/main.ts - Runtime coordinator → Room maze generation: generates layout
src/main.ts - Game controller → Maze parsing: parses layout
src/game/game.ts - Game controller → Player movement: moves player
src/game/game.ts - Game controller → Pellet scoring: scores pellets
src/game/game.ts - Game controller → Ghost movement: moves ghost
src/game/game.ts - Game controller → Game data types: uses game types
src/game/game.ts - Runtime coordinator → Three.js scene: creates scene
src/main.ts - Runtime coordinator → Maze board renderer: creates and draws
src/main.ts - Runtime coordinator → Character renderer: creates renderer
src/main.ts - Runtime coordinator → Game HUD: updates status
src/main.ts - Maze board renderer → World coordinates: maps grid cells
src/render/boardRenderer.ts - Character renderer → World coordinates: maps positions
src/render/characterRenderer.ts - Game HUD → Pellet scoring: counts remaining
src/ui/hud.ts - Game HUD → State validation: validates state
src/ui/hud.ts - Runtime coordinator → AR session adapter: creates AR session
src/main.ts - Runtime coordinator → Surface hit testing: queries placement
src/main.ts - Runtime coordinator → Room understanding: creates room scan
src/main.ts - Runtime coordinator → Placement marker: places marker
src/main.ts - AR session adapter → Browser XR: requests WebXR
src/xr/arSession.ts - Browser XR → Room understanding: provides room data