Commit 499216b7 authored by Alfakhori's avatar Alfakhori
Browse files

three v186

parent ebd6d6fc
Pipeline #12484 passed with stage
in 26 seconds
function downloadScene() { function downloadScene() {
const placedModels = getAllPlacedModels().map(model => { const placedModels = window.getAllPlacedModels().map((model) => {
const { lat, lng } = threeToLeaflet(model.position.x, model.position.z); const { lat, lng } = window.threeToLeaflet(
model.position.x,
model.position.z,
);
return { return {
name: model.modelConfig.name, name: model.modelConfig.name,
position: model.position, position: model.position,
...@@ -8,10 +11,10 @@ function downloadScene() { ...@@ -8,10 +11,10 @@ function downloadScene() {
scale: model.scale, scale: model.scale,
lat: lat, lat: lat,
lng: lng, lng: lng,
} };
}); });
console.log("Modelle: " + placedModels.length) console.log("Modelle: " + placedModels.length);
if (placedModels.length === 0) { if (placedModels.length === 0) {
showInfoDialog("Szene ist leer"); showInfoDialog("Szene ist leer");
return; return;
...@@ -27,7 +30,7 @@ function downloadScene() { ...@@ -27,7 +30,7 @@ function downloadScene() {
lat: geoLocation.latitude, lat: geoLocation.latitude,
lng: geoLocation.longitude, lng: geoLocation.longitude,
models: placedModels, models: placedModels,
} };
const sceneData = JSON.stringify(data, null, 1); const sceneData = JSON.stringify(data, null, 1);
const blob = new Blob([sceneData], { type: "application/json" }); const blob = new Blob([sceneData], { type: "application/json" });
...@@ -45,20 +48,20 @@ function downloadScene() { ...@@ -45,20 +48,20 @@ function downloadScene() {
} }
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) { fileInput.addEventListener("change", function (event) {
const file = event.target.files[0]; const file = event.target.files[0];
const fileName = file ? file.name : "Keine Datei ausgewählt" const fileName = file ? file.name : "Keine Datei ausgewählt";
if (!file) { if (!file) {
console.log("Keine Datei ausgewählt"); console.log("Keine Datei ausgewählt");
return; return;
} }
const reader = new FileReader(); const reader = new FileReader();
reader.onload = function(e) { reader.onload = function (e) {
try { try {
const sceneData = JSON.parse(e.target.result); const sceneData = JSON.parse(e.target.result);
loadedData(sceneData, fileName); loadedData(sceneData, fileName);
...@@ -71,3 +74,7 @@ function loadSceneFromFile(loadedData) { ...@@ -71,3 +74,7 @@ function loadSceneFromFile(loadedData) {
}); });
fileInput.click(); fileInput.click();
} }
/* 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;
...@@ -98,7 +100,7 @@ function init_map() { ...@@ -98,7 +100,7 @@ function init_map() {
// Add currently placed models to map // Add currently placed models to map
// ======================================================== // ========================================================
const models = getAllPlacedModels(); const models = window.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);
...@@ -210,7 +212,12 @@ function updateMap() { ...@@ -210,7 +212,12 @@ function updateMap() {
} }
// PERFORMANCE: Reuse the same Vector3 object. // PERFORMANCE: Reuse the same Vector3 object.
camera.getWorldPosition(cameraPosition); const activeCamera =
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.
...@@ -323,3 +330,9 @@ function roundTo(n, digits) { ...@@ -323,3 +330,9 @@ 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;
...@@ -79,7 +79,6 @@ function showStartScreen() { ...@@ -79,7 +79,6 @@ function showStartScreen() {
startScreen.appendChild(hftLogo); startScreen.appendChild(hftLogo);
/* ========================================================== /* ==========================================================
TITLE TITLE
========================================================== */ ========================================================== */
...@@ -190,7 +189,7 @@ function showStartScreen() { ...@@ -190,7 +189,7 @@ function showStartScreen() {
predefinedButton2 = null; predefinedButton2 = null;
// Start AR // Start AR
activateXR(sceneData); window.activateXR(sceneData);
}; };
/* ========================================================== /* ==========================================================
...@@ -198,7 +197,7 @@ function showStartScreen() { ...@@ -198,7 +197,7 @@ function showStartScreen() {
========================================================== */ ========================================================== */
loadButton.onclick = () => { loadButton.onclick = () => {
loadSceneFromFile((data, fileName) => { window.loadSceneFromFile((data, fileName) => {
if (data && fileName) { if (data && fileName) {
sceneData = data; sceneData = data;
sceneFileName = fileName; sceneFileName = fileName;
......
...@@ -9,8 +9,15 @@ ...@@ -9,8 +9,15 @@
<link rel="stylesheet" href="style.css"> <link rel="stylesheet" href="style.css">
<script src="https://unpkg.com/three@0.126.0/build/three.js"></script> <!-- Three.js (modern ES module setup) -->
<script src="https://unpkg.com/three@0.126.0/examples/js/loaders/GLTFLoader.js"></script> <script type="importmap">
{
"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>
...@@ -29,6 +36,7 @@ ...@@ -29,6 +36,7 @@
STANDARDMENÜ STANDARDMENÜ
============================================================ --> ============================================================ -->
<div id="menu-bar"> <div id="menu-bar">
<div <div
...@@ -299,7 +307,7 @@ ...@@ -299,7 +307,7 @@
============================================================ --> ============================================================ -->
<div id="app-version"> <div id="app-version">
v0.1.3 v0.1.186
</div> </div>
...@@ -307,21 +315,22 @@ ...@@ -307,21 +315,22 @@
JAVASCRIPT JAVASCRIPT
============================================================ --> ============================================================ -->
<script src="ar_start.js"></script> <!-- Debug console loads first so it can capture module errors/logs -->
<script src="ar_main.js"></script>
<script src="ar_debug_console.js"></script> <script src="ar_debug_console.js"></script>
<!-- Application modules -->
<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"
href="https://unpkg.com/leaflet/dist/leaflet.css" /> href="https://unpkg.com/leaflet/dist/leaflet.css" />
<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