ARHunt Development Memory
Tracks ARHunt development changes, including InstantDB fixes, overlay rendering solutions, and camera permission adjustments.
What this file does
Tracks ARHunt development changes, including InstantDB fixes, overlay rendering solutions, and camera permission adjustments.
When to use it
- Debugging AR overlay visibility issues with MindAR
- Resolving InstantDB import errors in static deployments
- Implementing real-time player progress tracking with InstantDB
- Managing camera initialization conflicts in WebAR apps
Assumes this stack
ARHunt Development Memory
This file tracks key changes made to the ARHunt project and development progress.
Recent Changes (October 7, 2025)
Fixed InstantDB Import Issue
Problem: The app was getting errors when trying to load InstantDB:
GET https://esm.sh/@instantdb/version@v0.22.6?target=es2022 net::ERR_ABORTED 500 (Internal Server Error)TypeError: Failed to fetch dynamically imported module: https://esm.sh/@instantdb/core@0.22.6
Solution: Replaced ESM.sh dynamic import with Skypack CDN and proper initialization:
-
Changed from dynamic import to static module loading:
- Before:
const { init, i, id } = await import('https://esm.sh/@instantdb/core@0.22.6'); - After: Added Skypack CDN script in
index.htmlthat makes InstantDB globally available
- Before:
-
Updated index.html:
- Added InstantDB import via Skypack CDN with proper ES module support
- Added event-driven initialization to ensure InstantDB loads before main script
-
Updated mind-hunt.js:
- Changed from async function with dynamic import to proper event-driven initialization
- Added dual event listener system that waits for both DOM ready and InstantDB ready
- Uses
window.InstantDBinstead of dynamic import
Files Modified:
index.html: Added Skypack CDN script for InstantDBmind-hunt.js: Refactored initialization to use global InstantDB object
Status: Fixed and tested locally. Ready for GitHub Pages deployment.
Project Architecture Notes
- Database: Uses InstantDB for real-time multiplayer features (discoveries notifications)
- AR Framework: MindAR + A-Frame for WebAR functionality
- Deployment: GitHub Pages (static hosting)
- Target Detection: Requires
assets/targets/targets.mindfile compiled from MindAR - Assets Structure:
assets/overlays/DA1.jpgthroughDA8.jpgfor target overlaysassets/targets/targets.mindfor AR target recognition
Recent Changes (October 7, 2025 - Session 2)
Enhanced InstantDB Player Progress Tracking
Enhancement: Comprehensive player progress tracking and analytics system
New Features Added:
-
Enhanced Database Schema:
gameSessions: Track complete game sessions with real-time progressdiscoveries: Detailed individual target discoveries with timingplayerStats: Player achievements and statistics across all games
-
Real-time Session Management:
- Creates session when player starts game
- Updates progress as each target is discovered
- Records completion time and session duration
- Tracks player statistics and achievements
-
Comprehensive Data Tracking:
- Player name and unique session ID
- Start time, completion time, and total duration
- Real-time progress percentage (0-100%)
- Individual target discovery timing and sequence
- Player statistics: total games, completion rate, best times
Database Schema Structure:
- gameSessions: Overall session tracking with progress updates
- discoveries: Individual target finds with detailed timing
- playerStats: Cumulative player achievements and records
Files Modified:
instant.schema.ts: Enhanced schema with comprehensive player trackingmind-hunt.js: Added session management and real-time progress updatesMEMORY.MD: Updated with new features
Key Functions Added:
createGameSession(): Initialize new game sessionupdateGameSession(): Real-time progress updatescompleteGameSession(): Finalize session with completion dataupdatePlayerStats(): Track cumulative player achievements
Recent Changes (October 7, 2025 - Session 3)
Simplified Overlay Implementation to Fix Rendering Issues
Problem: AR detection was working but overlay images weren't appearing visually on detected targets
Root Cause Analysis:
- Extensive debugging revealed AR detection was working perfectly
- Database logging, fireworks, and event handling all functional
- Issue was with overlay plane rendering due to overly complex setup
Solution: Simplified to match official MindAR example pattern:
-
HTML Changes:
- Removed complex material attributes from overlay planes
- Changed from
material="src: #asset; transparent: true; opacity: 1"to simplesrc="#asset" - Standardized all positions to
position="0 0 0"(official MindAR pattern) - Set standard dimensions:
height="0.552" width="1"
-
JavaScript Cleanup:
- Removed excessive overlay manipulation code that was forcing visibility/positioning
- Removed test elements that were added for debugging
- Simplified event handlers to focus on game logic, not overlay manipulation
- Let MindAR handle overlay visibility automatically
Implementation Now Follows Official Pattern:
<a-entity mindar-image-target="targetIndex: 0">
<a-plane src="#da1" position="0 0 0" height="0.552" width="1" rotation="0 0 0"></a-plane>
</a-entity>
Files Modified:
index.html: Simplified all 8 target overlay definitionsmind-hunt.js: Removed overlay manipulation code, kept clean event handlersMEMORY.MD: Updated with solution details
Recent Changes (October 7, 2025 - Session 3b)
Fixed Camera Permission Interference Issue
Critical Discovery: The overlay rendering issue was likely caused by camera permission checking that interfered with MindAR's camera initialization.
Problem:
- App was checking camera permissions by creating a stream and immediately stopping it
- This happened before MindAR tried to initialize its own camera access
- The stopped stream may have interfered with MindAR's ability to properly render overlays
Solution:
- Removed manual camera permission checking: Let MindAR handle camera permissions directly
- Simplified AR startup: Direct call to
startAR()without pre-checking permissions - Cleaned up overlay manipulation: Removed excessive debugging and manipulation code
- Trust MindAR's built-in handling: Let the library manage camera access and overlay visibility
Files Modified:
mind-hunt.js: RemovedcheckCameraPermissions()function and its usagemind-hunt.js: Simplified startup flow to let MindAR handle everythingindex.html: Cleaned up test overlays from target-4
Recent Changes (October 7, 2025 - Session 3c)
Keep Camera Running Continuously
New Approach: Instead of starting/stopping camera, keep it running but control game activation
Changes Made:
- AR container visible from start: Removed
hiddenclass fromar-containerin HTML - Start AR immediately: AR system starts when scene loads, not when user clicks "Start"
- Game activation flag: Added
gameActiveboolean to control target response - Continuous camera: Camera runs in background during name entry, overlays should initialize properly
Flow Now:
- Page loads → AR starts immediately → Camera active
- User enters name → Menu overlay still visible over camera feed
- User clicks "Start" → Menu hides, HUD shows,
gameActive = true - Targets now respond to detection events
Files Modified:
index.html: Removedhiddenfrom ar-containermind-hunt.js: Added gameActive flag and modified event handlersmind-hunt.js: AR starts on scene load instead of on button click
Expected Result: Overlays should now render properly since camera and AR system initialize fully before any interruption
Current Issues to Watch
- Test overlay visibility with simplified implementation on actual devices
- Monitor if further adjustments needed for different target aspect ratios
- Future: May need to update target images or MindAR compilation if detection issues arise
- Monitor database performance with increased data collection
What's inside
6 change entries with problems, solutions, and file modifications; 1 project architecture section; 1 current issues list
Change this for your project
- Replace
j7j7/ARHuntwith your repository name - Replace
assets/targets/targets.mindwith your compiled MindAR target file - Replace
assets/overlays/DA1.jpgthroughDA8.jpgwith your overlay images
Where it goes
Keep it in your repository where the agent or team that needs it will read it.
Worth borrowing
- Event-driven initialization that waits for both DOM and library readiness
- Keeping camera running continuously while controlling game activation with a boolean flag
- Simplifying overlay markup to match official library examples when debugging rendering
Related Documents
Zig 0.16.0 Context Document for LLMs
Documents breaking changes from Zig 0.13/0.14 to 0.16.0, covering syntax, I/O, build system, and standard library updates.
绘制对比图片 KITTI
Documents the topic remapping and data flow needed to connect Fast-LIO2 frontend with SC-PGO backend for KITTI evaluation.
Beads Workflow Context
Guides when to use bd graph-based issue tracker versus TodoWrite for session vs multi-session work, with commands and workflows.
EPIC: usda-data-crush-stats
Maps a multi-year USDA grape crush data pipeline from raw downloads through bronze, silver, and gold layers to final CSV fact and dimension tables.