forked from rajun/ar-test
3.0 KiB
3.0 KiB
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:
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
- Open your phone camera or any QR scanner app.
- Scan the old QR code.
- Look at the URL it opens, for example:
http://localhost:5173/ar/0gsk2w8h236474u - 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)
- Open your PocketBase Admin Dashboard:
http://localhost:8090/_/(or your PocketBase server URL). - Go to the
ar_assetscollection. - Click "New Record".
- In the
idfield 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). - Upload your new
.glb,.usdz, or.pngfiles and set the assetname. - 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:
{
"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:
- Add a "Custom ID / Reused QR ID" input field in the asset creation form.
- Pass the
idfield in theformDatasent to PocketBase during asset creation:
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
- Scan the old printed QR code to get the 15-character ID at the end of the
/ar/URL. - Create a new record in the
ar_assetsPocketBase collection. - Pass/Set the
idfield to match the old 15-character ID. - Test by scanning the old QR code — it will now display the new 3D asset!