Back to .md Directory

ARHunt Development Memory

This file tracks key changes made to the ARHunt project and development progress.

May 2, 2026
0 downloads
0 views
ai
View source

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:

  1. 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.html that makes InstantDB globally available
  2. 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
  3. 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.InstantDB instead of dynamic import

Files Modified:

  • index.html: Added Skypack CDN script for InstantDB
  • mind-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.mind file compiled from MindAR
  • Assets Structure:
    • assets/overlays/DA1.jpg through DA8.jpg for target overlays
    • assets/targets/targets.mind for 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:

  1. Enhanced Database Schema:

    • gameSessions: Track complete game sessions with real-time progress
    • discoveries: Detailed individual target discoveries with timing
    • playerStats: Player achievements and statistics across all games
  2. 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
  3. 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 tracking
  • mind-hunt.js: Added session management and real-time progress updates
  • MEMORY.MD: Updated with new features

Key Functions Added:

  • createGameSession(): Initialize new game session
  • updateGameSession(): Real-time progress updates
  • completeGameSession(): Finalize session with completion data
  • updatePlayerStats(): 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:

  1. HTML Changes:

    • Removed complex material attributes from overlay planes
    • Changed from material="src: #asset; transparent: true; opacity: 1" to simple src="#asset"
    • Standardized all positions to position="0 0 0" (official MindAR pattern)
    • Set standard dimensions: height="0.552" width="1"
  2. 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 definitions
  • mind-hunt.js: Removed overlay manipulation code, kept clean event handlers
  • MEMORY.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:

  1. Removed manual camera permission checking: Let MindAR handle camera permissions directly
  2. Simplified AR startup: Direct call to startAR() without pre-checking permissions
  3. Cleaned up overlay manipulation: Removed excessive debugging and manipulation code
  4. Trust MindAR's built-in handling: Let the library manage camera access and overlay visibility

Files Modified:

  • mind-hunt.js: Removed checkCameraPermissions() function and its usage
  • mind-hunt.js: Simplified startup flow to let MindAR handle everything
  • index.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:

  1. AR container visible from start: Removed hidden class from ar-container in HTML
  2. Start AR immediately: AR system starts when scene loads, not when user clicks "Start"
  3. Game activation flag: Added gameActive boolean to control target response
  4. 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: Removed hidden from ar-container
  • mind-hunt.js: Added gameActive flag and modified event handlers
  • mind-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

Related Documents