Commit 0333f048 authored by Alfakhori's avatar Alfakhori
Browse files

add predefined scenes

parent 39b81337
Pipeline #12472 passed with stage
in 23 seconds
...@@ -8,13 +8,38 @@ let sceneFileName = null; ...@@ -8,13 +8,38 @@ let sceneFileName = null;
let startButton = null; let startButton = null;
let loadButton = null; let loadButton = null;
let predefinedButton1 = null;
let predefinedButton2 = null;
/* ========================= */
/* PREDEFINED SCENE */
/* ========================= */
async function loadPredefinedScene(filePath, fileName) {
try {
const response = await fetch(filePath);
const data = await response.json();
sceneData = data;
sceneFileName = fileName;
console.log("Vordefinierte Szene geladen:", fileName);
} catch (error) {
console.error(
"Fehler beim Laden der vordefinierten Szene:",
error
);
}
}
/* ============================================================ */ /* ============================================================ */
/* Create the Start AR / Load Scene buttons */ /* Create the Start AR / Load Scene buttons */
/* ============================================================ */ /* ============================================================ */
function showStartScreen() { function showStartScreen() {
// Prevent duplicate buttons // Prevent duplicate buttons
if (startButton || loadButton) { if (startButton || loadButton || predefinedButton1 || predefinedButton2) {
return; return;
} }
...@@ -58,18 +83,22 @@ function showStartScreen() { ...@@ -58,18 +83,22 @@ function showStartScreen() {
/* START AR CLICK */ /* START AR CLICK */
/* ========================= */ /* ========================= */
startButton.onclick = () => { startButton.onclick = () => {
// Remove start-page buttons // Remove start-page buttons
startButton.remove(); startButton.remove();
loadButton.remove(); loadButton.remove();
predefinedButton1.remove();
predefinedButton2.remove();
// Reset references // Reset references
startButton = null; startButton = null;
loadButton = null; loadButton = null;
predefinedButton1 = null;
predefinedButton2 = null;
// Start AR // Start AR
activateXR(sceneData); activateXR(sceneData);
}; };
/* ========================= */ /* ========================= */
/* LOAD SCENE CLICK */ /* LOAD SCENE CLICK */
...@@ -87,6 +116,59 @@ function showStartScreen() { ...@@ -87,6 +116,59 @@ function showStartScreen() {
} }
}); });
}; };
/* ========================= */
/* PREDEFINED SCENE 1 */
/* ========================= */
predefinedButton1 = document.createElement("button");
predefinedButton1.textContent = "Gengenbach Plaza";
predefinedButton1.style.cssText =
"position: fixed; " +
"top: 65%; " +
"left: 50%; " +
"transform: translate(-50%, -50%); " +
"padding: 15px; " +
"font-size: 18px;";
document.body.appendChild(predefinedButton1);
predefinedButton1.onclick = async () => {
await loadPredefinedScene(
"scenes/gengenbach-plaza.json",
"Gengenbach Plaza",
);
predefinedButton1.textContent = sceneFileName;
};
/* ========================= */
/* PREDEFINED SCENE 2 */
/* ========================= */
predefinedButton2 = document.createElement("button");
predefinedButton2.textContent = "Gengenbach Street";
predefinedButton2.style.cssText =
"position: fixed; " +
"top: 75%; " +
"left: 50%; " +
"transform: translate(-50%, -50%); " +
"padding: 15px; " +
"font-size: 18px;";
document.body.appendChild(predefinedButton2);
predefinedButton2.onclick = async () => {
await loadPredefinedScene(
"scenes/gengenbach-street.json",
"Gengenbach Street",
);
predefinedButton2.textContent = sceneFileName;
};
} }
/* ========================= */ /* ========================= */
......
{
"lat": 48.77967,
"lng": 9.17353,
"models": [
{
"name": "Bench",
"position": {
"x": 0.5059653520584106,
"y": -1.046484351158142,
"z": -2.4857735633850098
},
"rotation": {
"_x": 0,
"_y": 4.363323129985823,
"_z": 0,
"_order": "XYZ"
},
"scale": {
"x": 0.428,
"y": 0.428,
"z": 0.428
},
"lat": 48.77964766991615,
"lng": 9.173536897518753
},
{
"name": "Lantern",
"position": {
"x": 0.39047476649284363,
"y": -1.0823711156845093,
"z": -1.7634316682815552
},
"rotation": {
"_x": 0,
"_y": 0,
"_z": 0,
"_order": "XYZ"
},
"scale": {
"x": 3.7520000000000002,
"y": 3.7520000000000002,
"z": 3.7520000000000002
},
"lat": 48.7796541588238,
"lng": 9.17353532310565
}
]
}
\ No newline at end of file
{
"lat": 48.77966,
"lng": 9.17354,
"models": [
{
"name": "Bench",
"position": {
"x": -3.0674502849578857,
"y": -4.950973987579346,
"z": -5.41895055770874
},
"rotation": {
"_x": 0,
"_y": 0,
"_z": 0,
"_order": "XYZ"
},
"scale": {
"x": 0.5,
"y": 0.5,
"z": 0.5
},
"lat": 48.7796113207389,
"lng": 9.17349818331914
}
]
}
\ 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