Update viewer_ar_ios.js
Browse files- viewer_ar_ios.js +14 -28
viewer_ar_ios.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
/* viewer_ar_ios.js — AR PlayCanvas + GLB/USDZ via config.json (+ "sol" + mode mur)
|
| 2 |
- config.json : { "glb_url": "...", "usdz_url": "...", "sol": true|false }
|
| 3 |
-
- sol = true → plans horizontaux (sol) + rotation autour de l’axe
|
| 4 |
-
- sol = false → plans verticaux (mur) + rotation autour
|
| 5 |
- iOS : AR Quick Look (USDZ) — l’utilisateur place l’objet sur sol/mur
|
| 6 |
- Android/Desktop : WebXR AR + bouton "Lancer l’AR" + slider de rotation
|
| 7 |
*/
|
|
@@ -379,9 +379,8 @@
|
|
| 379 |
|
| 380 |
// Mode mur / sol
|
| 381 |
var wallMode = !PLACE_ON_FLOOR;
|
| 382 |
-
var
|
| 383 |
-
var
|
| 384 |
-
var wallAngleDeg = 0;
|
| 385 |
|
| 386 |
// Ombre blob (uniquement pour le sol)
|
| 387 |
var blob = null;
|
|
@@ -440,7 +439,7 @@
|
|
| 440 |
|
| 441 |
// Rotation via slider
|
| 442 |
var baseEulerX = 0, baseEulerZ = 0;
|
| 443 |
-
var rotationYDeg = 0;
|
| 444 |
|
| 445 |
function clamp360(d) { return Math.max(0, Math.min(360, d)); }
|
| 446 |
|
|
@@ -451,13 +450,14 @@
|
|
| 451 |
rotVal.textContent = String(Math.round(angleDeg)) + "°";
|
| 452 |
}
|
| 453 |
|
| 454 |
-
// Rotation murale : angle autour de
|
| 455 |
function setWallRotationFromSlider(angleDeg) {
|
| 456 |
wallAngleDeg = angleDeg;
|
| 457 |
-
var
|
| 458 |
-
|
| 459 |
var q = new pc.Quat();
|
| 460 |
-
|
|
|
|
| 461 |
modelRoot.setRotation(q);
|
| 462 |
}
|
| 463 |
|
|
@@ -626,25 +626,11 @@
|
|
| 626 |
applySliderRotation(y0);
|
| 627 |
} else {
|
| 628 |
// --- MODE MUR ---
|
| 629 |
-
//
|
| 630 |
-
|
| 631 |
-
var normalWorldFull = new pc.Vec3();
|
| 632 |
-
rot.transformVector(upLocal, normalWorldFull);
|
| 633 |
-
|
| 634 |
-
// 2) orienter l’objet exactement comme le plan (comme le cercle)
|
| 635 |
modelRoot.setRotation(rot);
|
| 636 |
-
wallBaseRot.copy(rot);
|
| 637 |
-
|
| 638 |
-
// 3) axe de rotation = projection horizontale de la normale (perpendiculaire au mur, horizontale)
|
| 639 |
-
var axis = new pc.Vec3(normalWorldFull.x, 0, normalWorldFull.z);
|
| 640 |
-
if (axis.lengthSq() < 1e-4) {
|
| 641 |
-
axis.set(0, 0, 1);
|
| 642 |
-
}
|
| 643 |
-
axis.normalize();
|
| 644 |
-
wallAxis.copy(axis);
|
| 645 |
-
|
| 646 |
-
// angle initial = 0
|
| 647 |
-
applySliderRotation(0);
|
| 648 |
}
|
| 649 |
|
| 650 |
placedOnce = true;
|
|
|
|
| 1 |
/* viewer_ar_ios.js — AR PlayCanvas + GLB/USDZ via config.json (+ "sol" + mode mur)
|
| 2 |
- config.json : { "glb_url": "...", "usdz_url": "...", "sol": true|false }
|
| 3 |
+
- sol = true → plans horizontaux (sol) + rotation autour de l’axe local Y (haut)
|
| 4 |
+
- sol = false → plans verticaux (mur) + rotation autour de l’axe local Y aligné à la normale du mur
|
| 5 |
- iOS : AR Quick Look (USDZ) — l’utilisateur place l’objet sur sol/mur
|
| 6 |
- Android/Desktop : WebXR AR + bouton "Lancer l’AR" + slider de rotation
|
| 7 |
*/
|
|
|
|
| 379 |
|
| 380 |
// Mode mur / sol
|
| 381 |
var wallMode = !PLACE_ON_FLOOR;
|
| 382 |
+
var wallBaseRot = new pc.Quat(); // orientation de base alignée au mur
|
| 383 |
+
var wallAngleDeg = 0; // angle autour de l’axe local Y
|
|
|
|
| 384 |
|
| 385 |
// Ombre blob (uniquement pour le sol)
|
| 386 |
var blob = null;
|
|
|
|
| 439 |
|
| 440 |
// Rotation via slider
|
| 441 |
var baseEulerX = 0, baseEulerZ = 0;
|
| 442 |
+
var rotationYDeg = 0; // pour le mode sol
|
| 443 |
|
| 444 |
function clamp360(d) { return Math.max(0, Math.min(360, d)); }
|
| 445 |
|
|
|
|
| 450 |
rotVal.textContent = String(Math.round(angleDeg)) + "°";
|
| 451 |
}
|
| 452 |
|
| 453 |
+
// Rotation murale : angle autour de l’axe local Y (qui pointe vers la normale du mur)
|
| 454 |
function setWallRotationFromSlider(angleDeg) {
|
| 455 |
wallAngleDeg = angleDeg;
|
| 456 |
+
var qLocal = new pc.Quat();
|
| 457 |
+
qLocal.setFromAxisAngle(pc.Vec3.UP, angleDeg);
|
| 458 |
var q = new pc.Quat();
|
| 459 |
+
// mur : orientation = rotation_de_base (alignée au mur) * rotation_locale_Y
|
| 460 |
+
q.mul2(wallBaseRot, qLocal);
|
| 461 |
modelRoot.setRotation(q);
|
| 462 |
}
|
| 463 |
|
|
|
|
| 626 |
applySliderRotation(y0);
|
| 627 |
} else {
|
| 628 |
// --- MODE MUR ---
|
| 629 |
+
// WebXR fournit rot tel que son axe Y est la normale du plan.
|
| 630 |
+
// On oriente donc directement le modèle comme le plan :
|
|
|
|
|
|
|
|
|
|
|
|
|
| 631 |
modelRoot.setRotation(rot);
|
| 632 |
+
wallBaseRot.copy(rot); // base : Y local du modèle = normale du mur
|
| 633 |
+
applySliderRotation(0); // pointe vers l’extérieur du mur, rotation autour de cette normale
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 634 |
}
|
| 635 |
|
| 636 |
placedOnce = true;
|