MikaFil commited on
Commit
8d7b305
·
verified ·
1 Parent(s): bdeb941

Update viewer_ar_ios.js

Browse files
Files changed (1) hide show
  1. viewer_ar_ios.js +20 -5
viewer_ar_ios.js CHANGED
@@ -1,7 +1,8 @@
1
- /* script_ar.js — AR PlayCanvas + GLB HuggingFace (GLB/USDZ via config.json)
2
  - Lit config.json (data-config) => { "glb_url": "...", "usdz_url": "..." }
3
- - Android/Desktop: WebXR AR (horizontaux uniquement) + slider yaw + blob shadow
4
- - iOS: fallback AR Quick Look (USDZ) pas de WebXR
 
5
  */
6
 
7
  (function () {
@@ -146,6 +147,20 @@
146
  el.textContent = msg;
147
  }
148
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
  function ensureQuickLookButton(USDZ_URL) {
150
  var btn = document.getElementById("ios-quicklook-btn");
151
  if (btn) return btn;
@@ -153,7 +168,7 @@
153
  var anchor = document.createElement("a");
154
  anchor.id = "ios-quicklook-btn";
155
  anchor.setAttribute("rel", "ar");
156
- anchor.setAttribute("href", USDZ_URL);
157
 
158
  var img = document.createElement("img");
159
  img.alt = "Voir en AR";
@@ -215,7 +230,7 @@
215
  } else {
216
  message("iOS détecté, mais aucun 'usdz_url' dans config.json.");
217
  }
218
- // Option: on pourrait lancer un viewer 3D non-AR ici si tu veux
219
  return;
220
  }
221
 
 
1
+ /* script_ar.js — AR PlayCanvas + GLB/USDZ via config.json
2
  - Lit config.json (data-config) => { "glb_url": "...", "usdz_url": "..." }
3
+ - iOS : fallback AR Quick Look (USDZ) avec #allowsContentScaling=0 (pas de zoom)
4
+ - Android/Desktop : WebXR AR (horizontaux uniquement) + slider yaw + blob shadow
5
+ - Éclairage PBR par défaut (sans WebXR light estimation)
6
  */
7
 
8
  (function () {
 
147
  el.textContent = msg;
148
  }
149
 
150
+ // Construit l'URL Quick Look avec allowsContentScaling=0
151
+ function buildQuickLookHref(usdzUrl) {
152
+ try {
153
+ var u = new URL(usdzUrl, window.location.href);
154
+ var hash = u.hash ? u.hash.replace(/^#/, '') : '';
155
+ var params = new URLSearchParams(hash);
156
+ params.set('allowsContentScaling', '0');
157
+ u.hash = params.toString();
158
+ return u.toString();
159
+ } catch (e) {
160
+ return usdzUrl + (usdzUrl.indexOf('#') >= 0 ? '&' : '#') + 'allowsContentScaling=0';
161
+ }
162
+ }
163
+
164
  function ensureQuickLookButton(USDZ_URL) {
165
  var btn = document.getElementById("ios-quicklook-btn");
166
  if (btn) return btn;
 
168
  var anchor = document.createElement("a");
169
  anchor.id = "ios-quicklook-btn";
170
  anchor.setAttribute("rel", "ar");
171
+ anchor.setAttribute("href", buildQuickLookHref(USDZ_URL)); // << blocage du scaling
172
 
173
  var img = document.createElement("img");
174
  img.alt = "Voir en AR";
 
230
  } else {
231
  message("iOS détecté, mais aucun 'usdz_url' dans config.json.");
232
  }
233
+ // Option : lancer un viewer 3D non-AR ici si désiré.
234
  return;
235
  }
236