Commit aa2ed718 authored by Matthias Betz's avatar Matthias Betz
Browse files

initial release

parent 6edaad85
// eslint-disable-next-line import/no-extraneous-dependencies
// const sharedLib = require('eslint-config-airbnb-typescript/lib/shared.js');
module.exports = {
root: true,
extends: ['@vcsuite/eslint-config/vue-ts'],
env: {
node: true,
},
rules: {
'no-restricted-syntax': 'off',
},
overrides: [
{
files: ['*.ts', '*.vue'],
parserOptions: {
project: ['./tsconfig.json', './tests/tsconfig.json'],
},
rules: {
'@typescript-eslint/no-non-null-assertion': 'off',
},
},
],
ignorePatterns: ['dist/', 'node_modules/'],
};
# Created by https://www.toptal.com/developers/gitignore/api/vue,vuejs,visualstudiocode,node
# Edit at https://www.toptal.com/developers/gitignore?templates=vue,vuejs,visualstudiocode,node
### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional stylelint cache
.stylelintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# parcel-bundler cache (https://parceljs.org/)
.cache
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# vuepress v2.x temp and cache directory
.temp
# Docusaurus cache and generated files
.docusaurus
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
### Node Patch ###
# Serverless Webpack directories
.webpack/
# Optional stylelint cache
# SvelteKit build / generate output
.svelte-kit
### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
!.vscode/*.code-snippets
# Local History for Visual Studio Code
.history/
# Built Visual Studio Code Extensions
*.vsix
### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide
### Vue ###
# gitignore template for Vue.js projects
#
# Recommended template: Node.gitignore
# TODO: where does this rule come from?
docs/_book
# TODO: where does this rule come from?
test/
### Vuejs ###
# Recommended template: Node.gitignore
dist/
npm-debug.log
yarn-error.log
# End of https://www.toptal.com/developers/gitignore/api/vue,vuejs,visualstudiocode,node
registry=https://registry.npmjs.org
dist/
plugin-assets/
public/
test-report.xml
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
# test output
.nyc_output
coverage
# static output
docs
# index.html (prettier does not take modern html 5 rules that closing tags for void elements should be avoided)
assets/index.html
# v1.0.0
Initial Release
\ No newline at end of file
# SmartVillages2
## Plugin Configuration
## Getting started
The plugin has two configuration properties that can be configured in the plugin configuration of the map.
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
The converter service can be found [here](https://transfer.hft-stuttgart.de/gitlab/lgl/smartvillages2-converter).
The instructions property can be a link to a pdf or html or anything else.
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
## Add your files
- [ ] [Create](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#create-a-file) or [upload](https://docs.gitlab.com/ee/user/project/repository/web_editor.html#upload-a-file) files
- [ ] [Add files using the command line](https://docs.gitlab.com/ee/gitlab-basics/add-file.html#add-a-file-using-the-command-line) or push an existing Git repository with the following command:
```
cd existing_repo
git remote add origin https://transfer.hft-stuttgart.de/gitlab/lgl/smartvillages2.git
git branch -M master
git push -uf origin master
```
## Integrate with your tools
- [ ] [Set up project integrations](https://transfer.hft-stuttgart.de/gitlab/lgl/smartvillages2/-/settings/integrations)
## Collaborate with your team
- [ ] [Invite team members and collaborators](https://docs.gitlab.com/ee/user/project/members/)
- [ ] [Create a new merge request](https://docs.gitlab.com/ee/user/project/merge_requests/creating_merge_requests.html)
- [ ] [Automatically close issues from merge requests](https://docs.gitlab.com/ee/user/project/issues/managing_issues.html#closing-issues-automatically)
- [ ] [Enable merge request approvals](https://docs.gitlab.com/ee/user/project/merge_requests/approvals/)
- [ ] [Automatically merge when pipeline succeeds](https://docs.gitlab.com/ee/user/project/merge_requests/merge_when_pipeline_succeeds.html)
## Test and Deploy
Use the built-in continuous integration in GitLab.
- [ ] [Get started with GitLab CI/CD](https://docs.gitlab.com/ee/ci/quick_start/index.html)
- [ ] [Analyze your code for known vulnerabilities with Static Application Security Testing(SAST)](https://docs.gitlab.com/ee/user/application_security/sast/)
- [ ] [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/ee/topics/autodevops/requirements.html)
- [ ] [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/ee/user/clusters/agent/)
- [ ] [Set up protected environments](https://docs.gitlab.com/ee/ci/environments/protected_environments.html)
***
# Editing this README
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thank you to [makeareadme.com](https://www.makeareadme.com/) for this template.
## Suggestions for a good README
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
## Name
Choose a self-explaining name for your project.
## Description
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
## Badges
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
## Visuals
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
## Installation
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
## Usage
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
## Support
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
## Roadmap
If you have ideas for releases in the future, it is a good idea to list them in the README.
## Contributing
State if you are open to contributions and what your requirements are for accepting them.
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
## Authors and acknowledgment
Show your appreciation to those who have contributed to the project.
## License
For open source projects, say how it is licensed.
## Project status
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
"plugins": [
{
"name": "smartvillages2",
"entry": "plugins/smartvillages2/index.js?mapVersion=5.1.8",
"convertLink": "<Link to the converter service>",
"instructions": "<Link to a instructions document>"
}
],
```
\ No newline at end of file
This diff is collapsed.
{
"name": "smartvillages2",
"version": "1.0.0",
"description": "Plugin des SmartVillages2 Projekts",
"type": "module",
"main": "src/index.js",
"scripts": {
"prepublishOnly": "vcmplugin build",
"build": "vcmplugin build",
"bundle": "vcmplugin bundle",
"start": "vcmplugin serve",
"preview": "vcmplugin preview",
"buildStagingApp": "vcmplugin buildStagingApp",
"lint:js": "eslint . --ext .vue,.js,.cjs,.mjs,.ts,.cts,.mts",
"lint:prettier": "prettier --check .",
"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"
},
"author": "Matthias Betz <matthias.betz@hft-stuttgart.de>",
"license": "AGPLv3",
"keywords": [
"vcmap",
"plugin"
],
"files": [
"src/",
"dist/",
"plugin-assets/",
"LICENSE.md",
"README.md",
"CHANGELOG.md"
],
"exports": {
".": "src/index.js",
"./dist": "./dist/index.js"
},
"eslintIgnore": [
"node_modules",
"dist",
"plugin-assets"
],
"eslintConfig": {
"root": true,
"extends": "@vcsuite/eslint-config/vue"
},
"prettier": "@vcsuite/eslint-config/prettier.js",
"dependencies": {
"three": "^0.169.0"
},
"peerDependencies": {
"@vcmap-cesium/engine": "^4.0.3",
"@vcmap/core": "^5.3.0",
"@vcmap/ui": "^5.2.4",
"ol": "^7.5.2"
},
"devDependencies": {
"@vcmap/plugin-cli": "^3.1.2",
"@vcsuite/eslint-config": "^3.0.7",
"@vitest/coverage-v8": "^1.6.0",
"jest-canvas-mock": "^2.5.2",
"jsdom": "^24.1.0",
"resize-observer-polyfill": "^1.5.1",
"vitest": "^1.6.0"
},
"mapVersion": "^5.0"
}
import { ToolboxType, WindowSlot, NotificationType } from '@vcmap/ui';
import { Cesium3DTileStyle, Math as CMath, ConstantProperty, Transforms, HeadingPitchRoll, Cesium3DTileset } from '@vcmap-cesium/engine';
import { AbstractInteraction, EventType } from '@vcmap/core';
import { name, version, mapVersion } from '../package.json';
import BIMOptions, { windowId } from './upload.vue';
import objectList, {} from './objectList.vue';
let url;
let model;
let conditions = [[true, true]];
let activeMouseEvent;
let currentMousePosition;
let heightDif = 0;
const hpRollMap = new Map();
let placedModels = [];
let hpRoll;
let app;
const hidingFeatures = [];
const hidingListener = function(tile) {
let allHidden = true;
for (const featureToHide of hidingFeatures) {
if (featureToHide.loops < 3) {
allHidden = false;
const feature = tile.content.getFeature(featureToHide.id);
if (feature !== undefined) {
app.maps.activeMap.layerCollection.globalHider.addFeature("manual", feature);
app.maps.activeMap.layerCollection.globalHider.hideObjects(["manual"]);
featureToHide.loops++;
}
}
}
if (allHidden) {
const primitives = app.maps.activeMap.getScene().primitives;
for (let i = 0; i < primitives.length; i++) {
const tileSet = primitives.get(i);
if (!tileSet instanceof Cesium3DTileset) {
continue;
}
tileSet.tileVisible.removeEventListener(hidingListener);
}
}
};
function updateHideCondition(gmlId) {
conditions.unshift(['${gml_id} === "' + gmlId + '"', false]);
}
function saveObjects() {
const outputObject = {};
const outputArray = [];
for (const m of placedModels) {
const tempRoll = hpRollMap.get(m.model);
let heading = 0;
if (tempRoll !== undefined) {
heading = tempRoll.heading;
}
outputArray.push({
name: m.name,
position: m.model.position.getValue(),
heading: heading,
});
}
outputObject.placedObjects = outputArray;
const hiddenObjects = [];
for (const o of hidingFeatures) {
hiddenObjects.push(o.id);
}
outputObject.hiddenObjects = hiddenObjects;
let textData = JSON.stringify(outputObject);
let blobData = new Blob([textData], {type: "application/json"});
saveFile('ObjektPlatzierung.json', window.URL.createObjectURL(blobData));
}
function saveFile(fileName, urlFile){
let a = document.createElement("a");
a.style = "display: none";
document.body.appendChild(a);
a.href = urlFile;
a.download = fileName;
a.click();
window.URL.revokeObjectURL(urlFile);
a.remove();
}
function setupModel(vcsApp, windowPos, url, name) {
const vcMap = vcsApp.maps.activeMap;
const scene = vcMap.getScene();
const ray = scene.camera.getPickRay(windowPos);
const center = scene.globe.pick(ray, scene);
heightDif = 0;
// Add the model to the viewer
model = vcMap.getEntities().add({
name: name,
position: center,
model: {
uri: url,
show: true,
},
});
placedModels.push({
model: model,
name: name,
});
vcMap.requestRender();
const interaction = new MoveInteraction();
interaction.setActive(EventType.CLICKMOVE);
activeMouseEvent = vcsApp.maps.eventHandler.addExclusiveInteraction(interaction, () => {});
}
function removePlacedModel(modelToBeRemoved) {
placedModels = placedModels.filter(function(m) {
return m.model !== 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
);
pickResult.z = pickResult.z + heightDif;
model.position.setValue(pickResult);
}
return event;
}
}
class HeightInteraction extends AbstractInteraction {
async pipe(event) {
// prevent the event from beeing passed to the next interaction within the chain
event.stopPropagation = false;
if (model === undefined) {
if (activeMouseEvent !== undefined) {
activeMouseEvent();
}
return event;
}
if (event.pointerEvent === 2) {
if (activeMouseEvent !== undefined) {
currentMousePosition = undefined;
activeMouseEvent();
return event;
}
} else if (event.pointerEvent === 3) {
if (currentMousePosition === undefined) {
currentMousePosition = [event.windowPosition.x, event.windowPosition.y];
return event;
}
const dif = event.windowPosition.y - currentMousePosition[1];
if (dif === 0) {
return event;
}
heightDif = heightDif - (dif / 50);
let pos = model.position.getValue();
currentMousePosition = [event.windowPosition.x, event.windowPosition.y];
pos.z = pos.z - (dif / 50);
model.position.setValue(pos);
}
return event;
}
}
class RotateAction extends AbstractInteraction {
async pipe(event) {
// prevent the event from beeing passed to the next interaction within the chain
event.stopPropagation = false;
if (model === undefined) {
if (activeMouseEvent !== undefined) {
activeMouseEvent();
}
return event;
}
if (event.pointerEvent === 2) {
if (activeMouseEvent !== undefined) {
currentMousePosition = undefined;
activeMouseEvent();
return event;
}
} else if (event.pointerEvent === 3) {
if (currentMousePosition === undefined) {
currentMousePosition = [event.windowPosition.x, event.windowPosition.y];
return event;
}
const dif = event.windowPosition.x - currentMousePosition[0];
if (dif === 0) {
return event;
}
currentMousePosition = [event.windowPosition.x, event.windowPosition.y];
const modelPos = model.position.getValue();
const deltaRadians = CMath.toRadians(dif / 3);