Back to Main

FloorARSession

Fallback with Google SceneViewer and Apple AR Quick Look

Place you model on a detected floor

import { FloorARSession, SceneViewerSession, QuickLookSession } from "@egjs/view3d";



/*

 * Sessions will be used in the order in which they are added.

 */



 // WebXR API based AR session, this will use the currently displayed model.

const floorSession = new FloorARSession({

  // Root element for dom-overlay above AR session

  overlayRoot: overlay,

  // Element to show loading indicator until the floor is found.

  loadingEl: "#loading",

  // Prevent entering to AR session without dom-overlay feature.

  forceOverlay: true,

}).on("start", () => {

  overlay.style.display = "flex";

}).on("end", () => {

  overlay.style.display = "none";

});

view3d.xr.addSession(floorSession);






// Fallback, for iOS11+ devices

view3d.xr.addSession(new QuickLookSession({

  file: new URL("../asset/statua.usdz", location.href).href,

}));



// You can attach handler on any button you make

arButton.addEventListener("click", async () => {

  view3d.xr.enter().catch(err => {

    alert(err);

    console.error(err);

  });

});

exitButton.addEventListener("click", () => {

  view3d.xr.exit();

});

          
View in AR
SEARCHING FOR FLOOR...