{"id":20641832,"url":"https://github.com/thisistheplace/dash-wtgviewer","last_synced_at":"2025-04-16T01:37:04.240Z","repository":{"id":65369378,"uuid":"524783616","full_name":"thisistheplace/dash-wtgviewer","owner":"thisistheplace","description":"Wind turbine generator foundation viewer developed as a Plotly Dash Component","archived":false,"fork":false,"pushed_at":"2023-02-09T11:54:22.000Z","size":102261,"stargazers_count":17,"open_issues_count":4,"forks_count":8,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-10T17:06:42.480Z","etag":null,"topics":["3d","3d-graphics","3d-models","dash","flask","leaflet","leafletjs","offshore-wind","plotly-dash","pydantic","python","react-three-drei","react-three-fiber","threejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thisistheplace.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-08-14T21:28:39.000Z","updated_at":"2024-12-24T14:06:24.000Z","dependencies_parsed_at":"2023-02-16T05:46:08.728Z","dependency_job_id":null,"html_url":"https://github.com/thisistheplace/dash-wtgviewer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thisistheplace%2Fdash-wtgviewer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thisistheplace%2Fdash-wtgviewer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thisistheplace%2Fdash-wtgviewer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thisistheplace%2Fdash-wtgviewer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thisistheplace","download_url":"https://codeload.github.com/thisistheplace/dash-wtgviewer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249182782,"owners_count":21226122,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["3d","3d-graphics","3d-models","dash","flask","leaflet","leafletjs","offshore-wind","plotly-dash","pydantic","python","react-three-drei","react-three-fiber","threejs"],"created_at":"2024-11-16T16:06:49.011Z","updated_at":"2025-04-16T01:37:04.223Z","avatar_url":"https://github.com/thisistheplace.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dash_wtgviewer\n\n`dash_wtgviewer` is a React component library developed for compatibility with Plotly Dash.\n\nThis library aims to provide efficient 3D visualisation of geo located offshore wind turbine\nstructures within a wind farm and includes the following features:\n- Map overlay of wind farm and wind turbine locations using https://react-leaflet.js.org/\n- 3D visualisation of wind farm and wind turbines using [threejs](https://threejs.org), [react-three-fibre](https://docs.pmnd.rs/react-three-fiber/getting-started/introduction) and [drei](https://github.com/pmndrs/drei) \n- Environmental rendering using https://threejs.org/examples/webgl_shaders_ocean.html\n- Generic wind turbine model definition using [pydantic](https://docs.pydantic.dev), which is compatible\nwith [FastAPI](https://fastapi.tiangolo.com) and conforms to [OpenAPI](https://www.openapis.org/)\n\nA live demo of it's functionality is available at https://spillthebeans.beancandesign.com/wind\n\n![demo](dash_wtgviewer.gif)\n\n## Usage\nInstall `dash-wtgviewer` into your python environment using:\n```bash\npython -m pip install dash_wtgviewer\n```\n\nCreate a compatible model using the included [pydantic](https://docs.pydantic.dev) classes:\n```python\n# some example imports\nfrom dash_wtgviewer.model import Model, Foundation, Blade, Nacelle, Rotor, Hub, Tower\nfrom dash_wtgviewer.model.fea.elements import Tube, Cuboid, Cone, ElementSet, ConicalTube\nfrom dash_wtgviewer.model.fea.nodes import Node\nfrom dash_wtgviewer.model.geometry.vectors import Vector3\n\n# create model components\nblades = [\n    Blade(\n        name=f\"Blade_{idx}\",\n        # Url to blade .gltf or .glb file which Dash is serving in the assets directory\n        # This blade model should have it's length orientated with the X axis\n        url='assets/path/to/my/blade/model.glb',\n        scale=Vector3(x=1, y=0.5, z=0.5),\n    )\n    for idx in range(1, 4)\n]\n\nhub = Hub(\n    cone=Cone(\n        nodes=[\n            Node(x=0, y=0, z=0),\n            Node(x=2, y=0, z=0),\n        ],\n        diameter=1,\n    )\n)\n\nrotor = Rotor(\n    blades=blades,\n    hub=hub,\n    node=Node(x=1, y=0, z=10)\n)\n...\n\n# create model\nmodel = Model(\n    name=\"model\", foundation=foundation, nacelle=nacelle, rotor=rotor, tower=tower\n)\n\n# write model to json to be loaded by the Dash server and served as a dict\n# to the DashWtgviewer component\nwith open(\"assets/path/to/my/model.json\", \"w\") as f:\n    f.write(model.json(indent=4))\n```\n\nInclude the `dash-wtgviewer` component in your dash app:\n```python\nfrom dash_wtgviewer import DashWtgviewer\napp.layout = html.Div(\n    DashWtgviewer(\n        id=\"my-unique-id\",\n        model=json.load(open(\"assets/path/to/my/model.json\", \"r\")),\n        show_map=True,\n        environment=True,\n        tooltip=True,\n        stats=True,\n        map={\n            \"center\": {\"id\": \"center\", \"lat\": 52.29733, \"lng\": 2.35038},\n            \"turbines\": {\n                \"positions\": json.load(open(\"assets/path/to/my/turbine_lat_lng_positions.json\", \"r\"))\n            },\n            \"boundary\": {\n                \"positions\": json.load(open(\"assets/path/to/my/wind_farm_boundary_lat_lng_positions.json\", \"r\"))\n            }\n        },\n        results=json.load(open(\"assets/path/to/my/results.json\", \"r\")),\n        colorscale={\n            \"visible\": True,\n            \"min\": 0, # optional, else takes results minimum value\n            \"max\": 100 # optional, else takes results maximum value\n        }\n    )\n)\n```\n\n### react-leaflet requirements\nThis package uses [react-leaflet](https://react-leaflet.js.org/) which requires the following\ncss sheets to be included in your Dash app:\n\n```python\nfrom dash import Dash\n# external CSS stylesheets\nexternal_stylesheets = [\n    {\n        'href': 'https://unpkg.com/leaflet@1.9.2/dist/leaflet.css',\n        'rel': 'stylesheet',\n        'integrity': 'sha256-sA+zWATbFveLLNqWO2gtiw3HL/lh1giY/Inf1BJ0z14=',\n        'crossorigin': ''\n    },\n    {\n        'href': 'https://unpkg.com/leaflet@1.9.2/dist/leaflet.js',\n        'rel': 'stylesheet',\n        'integrity': 'sha256-o9N1jGDZrf5tS+Ft4gbIK7mYMipq9lqpVJ91xHSyKhg=',\n        'crossorigin': ''\n    }\n]\napp = Dash(\n    external_stylesheets=external_stylesheets\n)\n```\n\n## Contributing\n\nSee [CONTRIBUTING.md](./CONTRIBUTING.md)\n\n### Install dependencies\n\nIf you have selected install_dependencies during the prompt, you can skip this part.\n\n1. Install npm packages\n    ```\n    $ npm install\n    ```\n2. Create a virtual env and activate.\n    ```\n    $ virtualenv venv\n    $ . venv/bin/activate\n    ```\n    _Note: venv\\Scripts\\activate for windows_\n\n3. Install python packages required to build components.\n    ```\n    $ pip install -r requirements.txt\n    ```\n4. Install the python packages for testing (optional)\n    ```\n    $ pip install -r tests/requirements.txt\n    ```\n\n### Develop code in `src/lib/components/DashWtgviewer.react.js`.\n\n- Test your code using node:\n    1. Build your code\n        ```\n        $ npm run build\n        ```\n    2. Start the node server:\n        ```\n        $ npm start\n        ```        \n    3. Visit http://localhost:8080 in your web browser\n\n- Test your code in a Python environment:\n    1. Build your code\n        ```\n        $ npm run build\n        ```\n    2. Run and modify the `usage.py` sample dash app:\n        ```\n        $ python usage.py\n        ```\n    3. Visit http://localhost:8080 in your web browser\n\n- Write tests for your component.\n    - A sample test is available in `tests/test_usage.py`, it will load `usage.py` and you can then automate interactions with selenium.\n    - Run the tests with `$ pytest tests`.\n    - The Dash team uses these types of integration tests extensively. Browse the Dash component code on GitHub for more examples of testing (e.g. https://github.com/plotly/dash-core-components)\n\n- Add custom styles to your component by putting your custom CSS files into your distribution folder (`dash_wtgviewer`).\n    - Make sure that they are referenced in `MANIFEST.in` so that they get properly included when you're ready to publish your component.\n    - Make sure the stylesheets are added to the `_css_dist` dict in `dash_wtgviewer/__init__.py` so dash will serve them automatically when the component suite is requested.\n\n- [Review your code](./review_checklist.md)\n\n### Create a production build and publish:\n\n1. Build your code:\n    ```\n    $ npm run build\n    ```\n2. Create a Python distribution\n    ```\n    $ python setup.py sdist bdist_wheel\n    ```\n    This will create source and wheel distribution in the generated the `dist/` folder.\n    See [PyPA](https://packaging.python.org/guides/distributing-packages-using-setuptools/#packaging-your-project)\n    for more information.\n\n3. Test your tarball by copying it into a new environment and installing it locally:\n    ```\n    $ pip install dash_wtgviewer-0.0.1.tar.gz\n    ```\n\n4. If it works, then you can publish the component to NPM and PyPI:\n    1. Publish on PyPI\n        ```\n        $ twine upload dist/*\n        ```\n    2. Cleanup the dist folder (optional)\n        ```\n        $ rm -rf dist\n        ```\n    3. Publish on NPM (Optional if chosen False in `publish_on_npm`)\n        ```\n        $ npm publish\n        ```\n        _Publishing your component to NPM will make the JavaScript bundles available on the unpkg CDN. By default, Dash serves the component library's CSS and JS locally, but if you choose to publish the package to NPM you can set `serve_locally` to `False` and you may see faster load times._\n\n5. Share your component with the community! https://community.plotly.com/c/dash\n    1. Publish this repository to GitHub\n    2. Tag your GitHub repository with the plotly-dash tag so that it appears here: https://github.com/topics/plotly-dash\n    3. Create a post in the Dash community forum: https://community.plotly.com/c/dash\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthisistheplace%2Fdash-wtgviewer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthisistheplace%2Fdash-wtgviewer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthisistheplace%2Fdash-wtgviewer/lists"}