Commit af3bbe7d authored by Alfakhori's avatar Alfakhori
Browse files

return to 126

parent ae2a0557
Pipeline #12486 passed with stage
in 26 seconds
function downloadScene() { function downloadScene() {
const placedModels = window.getAllPlacedModels().map((model) => { const placedModels = getAllPlacedModels().map(model => {
const { lat, lng } = window.threeToLeaflet( const { lat, lng } = threeToLeaflet(model.position.x, model.position.z);
model.position.x, return {
model.position.z, name: model.modelConfig.name,
); position: model.position,
return { rotation: model.rotation,
name: model.modelConfig.name, scale: model.scale,
position: model.position, lat: lat,
rotation: model.rotation, lng: lng,
scale: model.scale, }
lat: lat, });
lng: lng,
};
});
console.log("Modelle: " + placedModels.length);
if (placedModels.length === 0) {
showInfoDialog("Szene ist leer");
return;
}
if (!geoLocation) {
console.log("Standort nicht geladen");
showInfoDialog("Ihr Standort wurde noch nicht geladen");
return;
}
const data = { console.log("Modelle: " + placedModels.length)
lat: geoLocation.latitude, if (placedModels.length === 0) {
lng: geoLocation.longitude, showInfoDialog("Szene ist leer");
models: placedModels, return;
}; }
const sceneData = JSON.stringify(data, null, 1); if (!geoLocation) {
const blob = new Blob([sceneData], { type: "application/json" }); console.log("Standort nicht geladen");
const url = URL.createObjectURL(blob); showInfoDialog("Ihr Standort wurde noch nicht geladen");
const a = document.createElement("a"); return;
a.href = url; }
a.download = "scene.json";
a.style.display = "none";
document.body.appendChild(a); const data = {
a.click(); lat: geoLocation.latitude,
lng: geoLocation.longitude,
models: placedModels,
}
URL.revokeObjectURL(url); const sceneData = JSON.stringify(data, null, 1);
document.body.removeChild(a); const blob = new Blob([sceneData], { type: "application/json" });
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = "scene.json";
a.style.display = "none";
document.body.appendChild(a);
a.click();
URL.revokeObjectURL(url);
document.body.removeChild(a);
} }
function loadSceneFromFile(loadedData) { function loadSceneFromFile(loadedData) {
const fileInput = document.createElement("input"); const fileInput = document.createElement('input');
fileInput.type = "file"; fileInput.type = 'file';
fileInput.accept = "application/json"; fileInput.accept = 'application/json';
fileInput.addEventListener("change", function (event) {
const file = event.target.files[0];
const fileName = file ? file.name : "Keine Datei ausgewählt";
if (!file) {
console.log("Keine Datei ausgewählt");
return;
}
const reader = new FileReader(); fileInput.addEventListener('change', function(event) {
reader.onload = function (e) { const file = event.target.files[0];
try { const fileName = file ? file.name : "Keine Datei ausgewählt"
const sceneData = JSON.parse(e.target.result); if (!file) {
loadedData(sceneData, fileName); console.log("Keine Datei ausgewählt");
} catch (error) { return;
console.error("Fehler beim Verarbeiten der Datei:", error);
} }
};
reader.readAsText(file); const reader = new FileReader();
reader.onload = function(e) {
try {
const sceneData = JSON.parse(e.target.result);
loadedData(sceneData, fileName);
} catch (error) {
console.error("Fehler beim Verarbeiten der Datei:", error);
}
};
reader.readAsText(file);
}); });
fileInput.click(); fileInput.click();
} }
\ No newline at end of file
/* Expose functions used by the existing HTML and ar_start.js. */
window.downloadScene = downloadScene;
window.loadSceneFromFile = loadSceneFromFile;
This diff is collapsed.
import * as THREE from "three";
let init = false; let init = false;
let mymap; let mymap;
let userIcon; let userIcon;
...@@ -100,7 +98,7 @@ function init_map() { ...@@ -100,7 +98,7 @@ function init_map() {
// Add currently placed models to map // Add currently placed models to map
// ======================================================== // ========================================================
const models = window.getAllPlacedModels(); const models = getAllPlacedModels();
models.forEach((model) => { models.forEach((model) => {
const { lat, lng } = threeToLeaflet(model.position.x, model.position.z); const { lat, lng } = threeToLeaflet(model.position.x, model.position.z);
...@@ -212,12 +210,7 @@ function updateMap() { ...@@ -212,12 +210,7 @@ function updateMap() {
} }
// PERFORMANCE: Reuse the same Vector3 object. // PERFORMANCE: Reuse the same Vector3 object.
const activeCamera = camera.getWorldPosition(cameraPosition);
typeof window.getXRRenderCamera === "function"
? window.getXRRenderCamera()
: camera;
activeCamera.getWorldPosition(cameraPosition);
// PERFORMANCE: Do not update Leaflet if the user // PERFORMANCE: Do not update Leaflet if the user
// has not moved. // has not moved.
...@@ -330,10 +323,3 @@ function roundTo(n, digits) { ...@@ -330,10 +323,3 @@ function roundTo(n, digits) {
return parseFloat(n); return parseFloat(n);
} }
/* Expose map functions needed by the other application modules. */
window.init_map = init_map;
window.centerOnPlan = centerOnPlan;
window.threeToLeaflet = threeToLeaflet;
window.leafletToThree = leafletToThree;
window.roundTo = roundTo;
...@@ -79,6 +79,7 @@ function showStartScreen() { ...@@ -79,6 +79,7 @@ function showStartScreen() {
startScreen.appendChild(hftLogo); startScreen.appendChild(hftLogo);
/* ========================================================== /* ==========================================================
TITLE TITLE
========================================================== */ ========================================================== */
...@@ -189,7 +190,7 @@ function showStartScreen() { ...@@ -189,7 +190,7 @@ function showStartScreen() {
predefinedButton2 = null; predefinedButton2 = null;
// Start AR // Start AR
window.window.activateXR(sceneData); activateXR(sceneData);
}; };
/* ========================================================== /* ==========================================================
...@@ -197,7 +198,7 @@ function showStartScreen() { ...@@ -197,7 +198,7 @@ function showStartScreen() {
========================================================== */ ========================================================== */
loadButton.onclick = () => { loadButton.onclick = () => {
window.window.loadSceneFromFile((data, fileName) => { loadSceneFromFile((data, fileName) => {
if (data && fileName) { if (data && fileName) {
sceneData = data; sceneData = data;
sceneFileName = fileName; sceneFileName = fileName;
......
...@@ -9,15 +9,8 @@ ...@@ -9,15 +9,8 @@
<link rel="stylesheet" href="style.css"> <link rel="stylesheet" href="style.css">
<!-- Three.js (modern ES module setup) --> <script src="https://unpkg.com/three@0.126.0/build/three.js"></script>
<script type="importmap"> <script src="https://unpkg.com/three@0.126.0/examples/js/loaders/GLTFLoader.js"></script>
{
"imports": {
"three": "https://unpkg.com/three@0.186.0/build/three.module.js",
"three/addons/": "https://unpkg.com/three@0.186.0/examples/jsm/"
}
}
</script>
</head> </head>
<body> <body>
...@@ -306,7 +299,7 @@ ...@@ -306,7 +299,7 @@
============================================================ --> ============================================================ -->
<div id="app-version"> <div id="app-version">
v0.1.4 v0.1.3
</div> </div>
...@@ -314,14 +307,11 @@ ...@@ -314,14 +307,11 @@
JAVASCRIPT JAVASCRIPT
============================================================ --> ============================================================ -->
<!-- Debug console loads first so it can capture module errors/logs --> <script src="ar_start.js"></script>
<script src="ar_debug_console.js"></script>
<script src="ar_main.js"></script>
<!-- Application modules --> <script src="ar_debug_console.js"></script>
<script type="module" src="ar_main.js"></script>
<script type="module" src="ar_overviewmap.js"></script>
<script type="module" src="ar_download.js"></script>
<script type="module" src="ar_start.js"></script>
<link <link
rel="stylesheet" rel="stylesheet"
...@@ -329,7 +319,9 @@ ...@@ -329,7 +319,9 @@
<script src="https://unpkg.com/leaflet/dist/leaflet.js"></script> <script src="https://unpkg.com/leaflet/dist/leaflet.js"></script>
<script src="ar_overviewmap.js"></script>
<script src="ar_download.js"></script>
<!-- ============================================================ <!-- ============================================================
......
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