diff --git a/QR_CODE_REUSE_GUIDE.md b/QR_CODE_REUSE_GUIDE.md new file mode 100644 index 0000000..319cafe --- /dev/null +++ b/QR_CODE_REUSE_GUIDE.md @@ -0,0 +1,85 @@ +# Guide: How to Reuse Existing Printed QR Codes for New 3D Assets + +--- + +## 1. Why is the old QR code showing a missing/old asset? + +Every QR code generated by the system embeds a direct AR URL containing a specific **Asset Record ID**: +```text +https://your-domain.com/ar/0gsk2w8h236474u + ^^^^^^^^^^^^^^^ + PocketBase Asset Record ID +``` + +When you delete an asset in PocketBase and create a new one: +* PocketBase automatically generates a **new random 15-character ID** (e.g., `x9y8z7w6v5u4t3s`). +* Your previously printed or saved QR code is still pointing to the **old ID** (`0gsk2w8h236474u`), which no longer exists in the database. + +--- + +## 2. Step-by-Step Fix: Reusing Old QR Codes + +To make an existing physical or saved QR code load a new 3D model, you must ensure the new PocketBase asset record uses the **exact same Record ID** encoded in the old QR code. + +### Step 1: Find the Old Record ID from the QR Code +1. Open your phone camera or any QR scanner app. +2. Scan the old QR code. +3. Look at the URL it opens, for example: `http://localhost:5173/ar/0gsk2w8h236474u` +4. Copy the 15-character ID at the end of the link: **`0gsk2w8h236474u`** + +--- + +### Step 2: Create a New Asset with the Same Record ID + +#### Option A: Via PocketBase Admin UI (Easiest) +1. Open your PocketBase Admin Dashboard: `http://localhost:8090/_/` (or your PocketBase server URL). +2. Go to the **`ar_assets`** collection. +3. Click **"New Record"**. +4. In the **`id`** field at the top, manually paste your old ID (e.g., `0gsk2w8h236474u`). + > ⚠️ **Note**: PocketBase IDs must be exactly **15 characters** consisting of lowercase letters (`a-z`) and digits (`0-9`). +5. Upload your new `.glb`, `.usdz`, or `.png` files and set the asset `name`. +6. Click **Save**. + +Now, scanning the old QR code will immediately load your newly created asset! + +--- + +#### Option B: Via API / Postman / Code + +When sending a `POST` request to PocketBase (`/api/collections/ar_assets/records`), include the `id` field in the payload: + +```json +{ + "id": "0gsk2w8h236474u", + "name": "New Shirt Model 3D" +} +``` + +--- + +#### Option C: Enabling Custom ID in your Thob Admin Dashboard + +If you want to be able to enter an **"Existing / Custom QR ID"** directly inside your application dashboard: + +1. Add a **"Custom ID / Reused QR ID"** input field in the asset creation form. +2. Pass the `id` field in the `formData` sent to PocketBase during asset creation: + +```typescript +const formData = new FormData(); +if (customId) { + formData.append('id', customId); // PocketBase will use this exact ID! +} +formData.append('name', name); +formData.append('glb_file', glbFile); + +await pb.collection('ar_assets').create(formData); +``` + +--- + +## Summary Checklist + +- [x] Scan the old printed QR code to get the 15-character ID at the end of the `/ar/` URL. +- [x] Create a new record in the `ar_assets` PocketBase collection. +- [x] Pass/Set the `id` field to match the old 15-character ID. +- [x] Test by scanning the old QR code — it will now display the new 3D asset!