The 2D/3D Polygon Viewer is a web application that allows users to visualize polygons in both 2D and 3D using data from a JSON file. The application includes interactive features like pan, zoom, polygon selection, and 3D rotation. It runs locally using Node.js.
- Dropdown Menu: Lists all sections found under the
polygonsBySection
node in the JSON file. Each section corresponds to a different set of polygons. - Polygon Rendering: Upon selecting a section from the dropdown, all polygons within that section are rendered on the 2D viewer.
- Zoom and Pan: Users can zoom in and out, and pan across the viewer. Both horizontal and vertical axes adjust accordingly.
- Polygon Selection: Users can click on individual polygons to select them.
- Display All Polygons: Shows polygons from all sections on a 3D plane.
- Gridline: A gridline is drawn at the floor level, bound by the min/max coordinates of the polygons.
- Zoom, Rotate, Pan: Users can zoom, rotate, and pan across the 3D scene.
The coordinates for the vertices are stored in a JSON file. The relevant data is found under the polygonsBySection
node, where several sections are defined. Each section contains polygon data, including the coordinates of their vertices.
{
"polygonsBySection": {
"section1": [
{
"vertices": [[x1, y1], [x2, y2], [x3, y3], ...]
},
...
],
"section2": [
{
"vertices": [[x1, y1], [x2, y2], [x3, y3], ...]
},
...
]
}
}
Prerequisites
- Node.js (v16 or higher)
- npm (v7 or higher)
Installation
-
Clone the repository: git clone https://github.com/ceowapp/rocscience-test1.git
-
Install the required dependencies:
npm install
-
Running the Project Start the server:
node server.js
Open your browser and navigate to:
http://localhost:3000
You should now see the 2D and 3D viewers in your browser.
Controls
- 2D Viewer
- Zoom: Scroll in/out to zoom.
- Pan: Click and drag to pan around the view.
- Select Polygon: Click on any polygon to select it.
- 3D Viewer
- Zoom: Scroll in/out to zoom.
- Rotate: Click and drag to rotate the 3D view.
- Pan: Right-click and drag to pan across the view.
Screenshots
Contributing
If you'd like to contribute to this project, feel free to submit a pull request. For major changes, please open an issue first to discuss what you would like to change.
License
This project is licensed under the MIT License - see the LICENSE file for details.