Commit 7fb28ca0 authored by Luna Riegel's avatar Luna Riegel
Browse files

Code Cleaning

parent eb5683df
import { ToolboxType, WindowSlot, NotificationType } from '@vcmap/ui';
import {NotificationType, ToolboxType, WindowSlot} from '@vcmap/ui';
import * as Cesium from '@vcmap-cesium/engine';
import {
Cesium3DTileStyle,
Math as CMath,
Ellipsoid,
Cartesian3,
Cesium3DTileset,
Cesium3DTileStyle,
ConstantProperty,
Transforms,
Ellipsoid,
HeadingPitchRoll,
Cesium3DTileset,
Matrix4,
EntityCollection
Math as CMath,
Transforms
} from '@vcmap-cesium/engine';
import { AbstractInteraction, EventType } from '@vcmap/core';
import { name, version, mapVersion } from '../package.json';
import BIMOptions, { bimOptionsId } from './upload.vue';
import objectList, { objectListId } from './objectList.vue';
import scaleControl, { scaleControlId } from './scaleControl.vue';
import * as Cesium from "@vcmap-cesium/engine";
import {loadCatalogModel} from "./objectList.vue";
import {AbstractInteraction, EventType} from '@vcmap/core';
import {mapVersion, name, version} from '../package.json';
import BIMOptions, {bimOptionsId} from './upload.vue';
import objectList, {loadCatalogModel, objectListId} from './objectList.vue';
import scaleControl, {scaleControlId} from './scaleControl.vue';
let model;
let conditions = [[true, true]];
......@@ -195,7 +193,6 @@ class MoveInteraction extends AbstractInteraction {
let xDif = pickResult.x - initialPickResult.x;
let yDif = pickResult.y - initialPickResult.y;
let zDif = pickResult.z - initialPickResult.z;
// pickResult.z = pickResult.z + heightDif;
let pos = initialPosition.clone();
pos.x = pos.x + xDif;
pos.y = pos.y + yDif;
......@@ -304,8 +301,7 @@ class RotateAction extends AbstractInteraction {
if (hpRoll.heading < 0.0) {
hpRoll.heading += CMath.TWO_PI;
}
const orientation = new ConstantProperty(Transforms.headingPitchRollQuaternion(modelPos, hpRoll));
model.orientation = orientation;
model.orientation = new ConstantProperty(Transforms.headingPitchRollQuaternion(modelPos, hpRoll));
}
return event;
}
......@@ -358,7 +354,7 @@ export default function smartVillagesPlugin(config, baseUrl) {
const objects = JSON.parse(content);
const vcMap = app.maps.activeMap;
for (const loadingObject of objects.placedObjects) {
let objectUrl = undefined;
let objectUrl;
for (const loadedObject of pluginState.objects) {
if (loadedObject.name === loadingObject.name) {
objectUrl = loadedObject.url;
......@@ -367,7 +363,6 @@ export default function smartVillagesPlugin(config, baseUrl) {
}
if (objectUrl === undefined) {
if (loadingObject.fromCatalog === true){
// TODO: Fetch from catalog
// Load the model into memory
const model = await loadCatalogModel(loadingObject.name).catch(e => {
console.error(e);
......@@ -406,8 +401,7 @@ export default function smartVillagesPlugin(config, baseUrl) {
const roll = new HeadingPitchRoll();
hpRollMap.set(model, roll);
roll.heading = loadingObject.heading;
const orientation = new ConstantProperty(Transforms.headingPitchRollQuaternion(model.position.getValue(), roll));
model.orientation = orientation;
model.orientation = new ConstantProperty(Transforms.headingPitchRollQuaternion(model.position.getValue(), roll));
placedModels.push({
model: model,
......@@ -561,10 +555,6 @@ export default function smartVillagesPlugin(config, baseUrl) {
}
const map = vcsApp.maps.getByType("CesiumVisualisationType");
// tileset.allTilesLoaded.addEventListener(function() {
// console.log('All tiles are loaded');
// });
const bimGroup = {
id: 'bim-functions',
......
......@@ -125,9 +125,9 @@ const preloadedModels = ref({});
const defaultItems = [];
const items = ref(defaultItems);
let setupModelFunction = undefined;
let app = undefined;
let projectStateObject = undefined;
let setupModelFunction;
let app;
let projectStateObject;
async function loadCatalogsFromConfig(config) {
const configJson = JSON.parse(JSON.stringify(config));
......@@ -158,14 +158,15 @@ async function retrieveCatalogJson(link) {
try {
const response = await fetch(link, { signal: controller.signal });
if (!response.ok) {
throw new Error(`HTTP error ${response.status} for ${link}`);
console.error(`Received HTTP error ${response.status} for ${link}`);
return null;
}
return await response.json();
} catch (error) {
if (error.name === 'AbortError') {
console.warn(`Fetch aborted (timeout) for: ${link}`);
} else {
console.error(`Fetch failed for ${link}:`, error);
console.error(`Catalog.json request timed out: ${link}`);
}else{
console.error(`Encountered error during catalog.json request: ${link}`, error);
}
return null;
} finally {
......@@ -305,8 +306,6 @@ function uploadModel() {
});
let url = URL.createObjectURL(blob);
const loader = new GLTFLoader();
loader.load(url, function(gltf) {
let bounds = new THREE.Box3().setFromObject(gltf.scene);
......@@ -348,10 +347,11 @@ function uploadModel() {
},
// called when there is an error in the generation
function ( error ) {
function ( error ) {
app.notifier.add({
type: NotificationType.ERROR,
message: "Ein Fehler ist beim Laden der glTF Datei aufgetreten. Bitte vergewissern Sie sich, dass es sich um eine gültige glTF2.0 Datei handelt.",
message: "Ein Fehler ist beim Laden der glTF Datei aufgetreten. Bitte vergewissern Sie sich, dass es sich um eine gültige glTF2.0 Datei handelt." +
" Fehlermeldung: " + error.message,
timeout: 20000,
});
}, options);
......@@ -364,8 +364,6 @@ function uploadModel() {
});
});
}
reader.readAsArrayBuffer(file);
}
});
......@@ -433,7 +431,7 @@ function uploadModel() {
const dialog = ref(false);
setupModelFunction = setupModel;
projectStateObject = pluginState;
onMounted(()=>loadCatalogsFromConfig(config).then(response => {console.log("Object library loaded")}));
onMounted(()=>loadCatalogsFromConfig(config).then(() => {console.log("Object library loaded")}));
return {
draggable,
selectable,
......
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