Commit 29e6ece1 authored by Alfakhori's avatar Alfakhori
Browse files

fix

parent f2bf92b7
Pipeline #12470 passed with stage
in 24 seconds
...@@ -1204,28 +1204,67 @@ async function activateXR(sceneData = null) { ...@@ -1204,28 +1204,67 @@ async function activateXR(sceneData = null) {
// Show main menu // Show main menu
// ======================================================== // ========================================================
menuElements["menu-bar"].style.display = "flex"; document.getElementById("menu-bar").style.display = "flex";
// ======================================================== // ========================================================
// AR session ended // AR session ended
// ======================================================== // ========================================================
currentSession.addEventListener("end", () => { currentSession.addEventListener("end", () => {
console.log("AR session ended");
// ====================================================
// Stop the AR session reference
// ====================================================
currentSession = null; currentSession = null;
// Hide dynamic menu // ====================================================
// Remove the XR canvas
//
// This prevents the dark/black screen from remaining
// over the normal start page.
// ====================================================
if (canvas && canvas.parentNode) {
canvas.parentNode.removeChild(canvas);
}
document.getElementById("dynamic-menu").style.display = "none"; // ====================================================
// Hide dynamic AR menu
// ====================================================
const dynamicMenu = document.getElementById("dynamic-menu");
if (dynamicMenu) {
dynamicMenu.style.display = "none";
}
// Hide all application menus // ====================================================
// Hide AR menus
// ====================================================
menus.forEach((id) => { menus.forEach((id) => {
const element = menuElements[id]; const element = document.getElementById(id);
if (element) { if (element) {
element.style.display = "none"; element.style.display = "none";
} }
}); });
// ====================================================
// Clear selected model
// ====================================================
selectedPlacedModel = null;
// ====================================================
// Return to the normal start page
// ====================================================
if (typeof showStartScreen === "function") {
showStartScreen();
}
}); });
// ======================================================== // ========================================================
......
/* ========================= */ /* ========================= */
/* DEBUGGING UND START */ /* DEBUGGING UND START */
/* ========================= */ /* ========================= */
let sceneData = null;
let sceneFileName = null;
let startButton = null;
let loadButton = null;
/* ============================================================ */
/* Create the Start AR / Load Scene buttons */
/* ============================================================ */
function showStartScreen() {
// Prevent duplicate buttons
if (startButton || loadButton) {
return;
}
/* ========================= */
/* START AR */
/* ========================= */
startButton = document.createElement("button");
startButton.textContent = "Start AR";
startButton.style.cssText =
"position: fixed; " +
"top: 45%; " +
"left: 50%; " +
"transform: translate(-50%, -50%); " +
"padding: 15px; " +
"font-size: 18px;";
document.body.appendChild(startButton);
/* ========================= */
/* LOAD SCENE */
/* ========================= */
loadButton = document.createElement("button");
loadButton.textContent = sceneFileName || "Umgebung Laden";
loadButton.style.cssText =
"position: fixed; " +
"top: 55%; " +
"left: 50%; " +
"transform: translate(-50%, -50%); " +
"padding: 15px; " +
"font-size: 18px;";
document.body.appendChild(loadButton);
/* ========================= */
/* START AR CLICK */
/* ========================= */
startButton.onclick = () => {
// Remove start-page buttons
startButton.remove();
loadButton.remove();
// Reset references
startButton = null;
loadButton = null;
// Start AR
activateXR(sceneData);
};
/* ========================= */
/* LOAD SCENE CLICK */
/* ========================= */
loadButton.onclick = () => {
loadSceneFromFile((data, fileName) => {
if (data && fileName) {
sceneData = data;
sceneFileName = fileName;
loadButton.textContent = fileName;
} else {
loadButton.textContent = sceneFileName || "Umgebung Laden";
}
});
};
}
/* ========================= */
/* INITIAL START */
/* ========================= */
if (navigator.xr) { if (navigator.xr) {
let sceneData; showStartScreen();
const startButton = document.createElement('button'); } else {
startButton.textContent = 'Start AR'; alert("WebXR wird nicht unterstützt.");
startButton.style.cssText = "position: fixed; top: 45%; left: 50%; transform: translate(-50%, -50%); padding: 15px; font-size: 18px;"; }
document.body.appendChild(startButton);
startButton.onclick = () => {
startButton.remove();
loadButton.remove();
activateXR(sceneData);
};
const loadButton = document.createElement('button');
loadButton.textContent = 'Umgebung Laden';
loadButton.style.cssText = "position: fixed; top: 55%; left: 50%; transform: translate(-50%, -50%); padding: 15px; font-size: 18px;";
document.body.appendChild(loadButton);
loadButton.onclick = () => {
loadSceneFromFile((data, fileName) => {
if (data && fileName) {
loadButton.textContent = fileName;
sceneData = data
} else {
loadButton.textContent = 'Umgebung Laden';
}
});
};
} else {
alert('WebXR wird nicht unterstützt.');
}
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment