Commit 1090f529 authored by Matthias Betz's avatar Matthias Betz
Browse files

Merge branch 'dev' of transfer.hft-stuttgart.de:lgl/smartvillages2 into dev

parents 230a2982 0c3c6c9a
......@@ -11,10 +11,15 @@
"dependencies": {
"three": "^0.169.0"
},
"bin": {
"status": "bin/server-check.js"
},
"devDependencies": {
"@vcmap/plugin-cli": "^4.1.1",
"@vcsuite/eslint-config": "^4.0.0",
"@vitest/coverage-v8": "^3.1.4",
"axios": "^1.6.7",
"commander": "^11.0.0",
"jest-canvas-mock": "^2.5.2",
"jsdom": "^26.1.0",
"resize-observer-polyfill": "^1.5.1",
......@@ -2497,6 +2502,16 @@
}
}
},
"node_modules/@vcmap/plugin-cli/node_modules/commander": {
"version": "10.0.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-10.0.1.tgz",
"integrity": "sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=14"
}
},
"node_modules/@vcmap/rollup-plugin-vcs-ol": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/@vcmap/rollup-plugin-vcs-ol/-/rollup-plugin-vcs-ol-1.0.5.tgz",
......@@ -3204,6 +3219,13 @@
"node": ">= 0.4"
}
},
"node_modules/asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==",
"dev": true,
"license": "MIT"
},
"node_modules/autolinker": {
"version": "4.1.5",
"resolved": "https://registry.npmjs.org/autolinker/-/autolinker-4.1.5.tgz",
......@@ -3233,6 +3255,18 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/axios": {
"version": "1.10.0",
"resolved": "https://registry.npmjs.org/axios/-/axios-1.10.0.tgz",
"integrity": "sha512-/1xYAC4MP/HEG+3duIhFr4ZQXR4sQXOIe+o6sdqzeykGLx6Upp/1p8MHqhINOvGeP7xyNHe7tsiJByc4SSVUxw==",
"dev": true,
"license": "MIT",
"dependencies": {
"follow-redirects": "^1.15.6",
"form-data": "^4.0.0",
"proxy-from-env": "^1.1.0"
}
},
"node_modules/balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
......@@ -3584,14 +3618,27 @@
"dev": true,
"license": "MIT"
},
"node_modules/combined-stream": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
"dev": true,
"license": "MIT",
"dependencies": {
"delayed-stream": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/commander": {
"version": "10.0.1",
"resolved": "https://registry.npmjs.org/commander/-/commander-10.0.1.tgz",
"integrity": "sha512-y4Mg2tXshplEbSGzx7amzPwKKOCGuoSRP/CjEdwwk0FOGlUbq6lKuoyDZTNZkmxHdJtp54hdfY/JUrdL7Xfdug==",
"version": "11.1.0",
"resolved": "https://registry.npmjs.org/commander/-/commander-11.1.0.tgz",
"integrity": "sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=14"
"node": ">=16"
}
},
"node_modules/comment-parser": {
......@@ -3867,6 +3914,16 @@
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/depd": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
......@@ -5165,6 +5222,27 @@
"license": "ISC",
"peer": true
},
"node_modules/follow-redirects": {
"version": "1.15.9",
"resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.9.tgz",
"integrity": "sha512-gew4GsXizNgdoRyqmyfMHyAmXsZDk6mHkSxZFCzW9gwlbtOW44CDtYavM+y+72qD/Vq2l550kMF52DT8fOLJqQ==",
"dev": true,
"funding": [
{
"type": "individual",
"url": "https://github.com/sponsors/RubenVerborgh"
}
],
"license": "MIT",
"engines": {
"node": ">=4.0"
},
"peerDependenciesMeta": {
"debug": {
"optional": true
}
}
},
"node_modules/for-each": {
"version": "0.3.5",
"resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.5.tgz",
......@@ -5211,6 +5289,23 @@
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/form-data": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.3.tgz",
"integrity": "sha512-qsITQPfmvMOSAdeyZ+12I1c+CKSstAFAwu+97zrnWAbIr5u8wfsExUzCesVLC8NgHuRUqNN4Zy6UPWUTRGslcA==",
"dev": true,
"license": "MIT",
"dependencies": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"es-set-tostringtag": "^2.1.0",
"hasown": "^2.0.2",
"mime-types": "^2.1.12"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/forwarded": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.2.0.tgz",
......@@ -7441,6 +7536,13 @@
"node": ">= 0.10"
}
},
"node_modules/proxy-from-env": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
"integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==",
"dev": true,
"license": "MIT"
},
"node_modules/punycode": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
......
......@@ -16,7 +16,11 @@
"lint": "npm run lint:js && npm run lint:prettier",
"format": "prettier --write --list-different . && npm run lint:js -- --fix",
"test": "vitest",
"coverage": "vitest run --coverage"
"coverage": "vitest run --coverage",
"checkServer": "npx status"
},
"bin": {
"status": "./src/bin/server-check.js"
},
"author": "Matthias Betz <matthias.betz@hft-stuttgart.de>",
"license": "AGPLv3",
......@@ -64,7 +68,9 @@
"jest-canvas-mock": "^2.5.2",
"jsdom": "^26.1.0",
"resize-observer-polyfill": "^1.5.1",
"vitest": "^3.1.4"
"vitest": "^3.1.4",
"axios": "^1.6.7",
"commander": "^11.0.0"
},
"mapVersion": "^6.1"
}
#!/usr/bin/env node
import { Command } from 'commander';
import axios from 'axios';
const program = new Command();
program
.name('server-check')
.description('Checks if the plugin server is running and responsive')
.option('-u, --url <url>', 'Full server URL', 'http://localhost:5005')
.action(async ({ url }) => {
try {
const res = await axios.get(url, { timeout: 5000 });
console.log(`Server responded: HTTP ${res.status} ${res.statusText}`);
process.exit(0);
} catch (err) {
console.error(`Server did not respond: ${err.message}`);
process.exit(1);
}
});
program.parse(process.argv);
\ No newline at end of file
......@@ -5,12 +5,15 @@ 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";
let model;
let conditions = [[true, true]];
let activeMouseEvent;
let currentMousePosition;
let initialPosition;
let initialPickResult;
let heightDif = 0;
const hpRollMap = new Map();
let placedModels = [];
......@@ -144,7 +147,7 @@ function setupModel(vcsApp, windowPos, url, name) {
name: name,
});
vcMap.requestRender();
const interaction = new MoveInteraction();
const interaction = new PickPlaceInteraction();
interaction.setActive(EventType.CLICKMOVE);
activeMouseEvent = vcsApp.maps.eventHandler.addExclusiveInteraction(interaction, () => {});
}
......@@ -156,6 +159,41 @@ function removePlacedModel(modelToBeRemoved) {
}
class MoveInteraction extends AbstractInteraction {
async pipe(event) {
if (event.pointerEvent === 2) {
if (activeMouseEvent !== undefined) {
activeMouseEvent();
}
} else if (event.pointerEvent === 3 && model !== undefined) {
const cesiumMap = event.map;
const scene = cesiumMap.getScene();
const pickResult = scene.globe.pick(
event.ray,
scene
);
if (initialPickResult === undefined) {
initialPickResult = pickResult;
}
if (initialPosition === undefined) {
initialPosition = model.position.getValue().clone();
}
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;
pos.z = pos.z + zDif;
model.position.setValue(pos);
}
return event;
}
}
class PickPlaceInteraction extends AbstractInteraction {
async pipe(event) {
if (event.pointerEvent === 2) {
if (activeMouseEvent !== undefined) {
......@@ -204,8 +242,10 @@ class HeightInteraction extends AbstractInteraction {
}
heightDif = heightDif - (dif / 50);
let pos = model.position.getValue();
let cart = Cesium.Cartographic.fromCartesian(pos);
cart.height -= (dif/50);
pos = Cesium.Cartesian3.fromRadians(cart.longitude, cart.latitude, cart.height);
currentMousePosition = [event.windowPosition.x, event.windowPosition.y];
pos.z = pos.z - (dif / 50);
model.position.setValue(pos);
}
return event;
......@@ -381,10 +421,21 @@ export default function smartVillagesPlugin(config, baseUrl) {
const pick = vcsApp.maps.activeMap.getScene().pick(event.windowPosition);
if (pick !== undefined && pick.primitive !== undefined && pick.primitive.id !== undefined) {
model = pick.primitive.id
actions.push({
id: 'move',
name: 'Objekt platzieren',
callback() {
const interaction = new PickPlaceInteraction();
interaction.setActive(EventType.CLICKMOVE);
activeMouseEvent = vcsApp.maps.eventHandler.addExclusiveInteraction(interaction, () => { console.log("removed") });
},
});
actions.push({
id: 'move',
name: 'Objekt verschieben',
callback() {
initialPosition = undefined;
initialPickResult = undefined;
const interaction = new MoveInteraction();
interaction.setActive(EventType.CLICKMOVE);
activeMouseEvent = vcsApp.maps.eventHandler.addExclusiveInteraction(interaction, () => { console.log("removed") });
......
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