2021-11-13 07:18:04 -07:00
[![pipeline status ](https://gitlab.com/nicolalandro/obj2html/badges/main/pipeline.svg )](https://gitlab.com/nicolalandro/obj2html/-/commits/main)
2021-11-13 07:04:00 -07:00
[![coverage report ](https://gitlab.com/nicolalandro/obj2html/badges/main/coverage.svg )](https://gitlab.com/nicolalandro/obj2html/-/commits/main)
2021-11-14 08:13:28 -07:00
2021-11-14 08:09:05 -07:00
[![pypi package ](https://img.shields.io/badge/pypi%20package-obj2html-blue )](https://pypi.org/project/obj2html/)
2021-11-14 08:13:28 -07:00
[![License: MIT ](https://img.shields.io/badge/license-MIT-lightgray )](LICENSE)
[![Open In Colab ](https://colab.research.google.com/assets/colab-badge.svg )](https://colab.research.google.com/drive/11mWxDwAf1tR7vivAN18Vo8vLRvI9nT5T?usp=sharing)
2021-11-13 07:04:00 -07:00
2021-11-13 06:26:55 -07:00
# Obj2Html
This lib is able to transform an .obj file to HTML that use three.js.
In this way it is possible to have an interactive 3D view that can be used on the browser or into a jupyter notebook.
2021-11-14 07:41:53 -07:00
Install with `pip install obj2html` and use with `obj2html('model.obj', 'index.html')`
2021-11-13 08:15:35 -07:00
![](imgs/colab_sample.png)
2021-11-21 06:03:30 -07:00
* run into [jupyter notebook ](https://jupyter.org/ ) ([jupyter_example.ipynb](examples/jupyter_example.ipynb)):
2021-11-13 06:55:57 -07:00
```
2021-11-13 08:15:35 -07:00
! pip install obj2html
! wget https://gitlab.com/nicolalandro/obj2html/-/raw/main/test/assets/model.obj
2021-11-13 06:55:57 -07:00
from obj2html import obj2html
from IPython.display import display, HTML
2021-11-14 07:41:53 -07:00
obj2html('model.obj', 'index.html')
2021-11-13 06:55:57 -07:00
display(HTML('index.html'))
```
2021-11-21 06:03:30 -07:00
* run into [streamlit ](https://streamlit.io/ ) app ([streamlit_example.py](examples/streamlit_example.py)):
```
# pip install obj2html streamlit
# have a model.obj (wget https://gitlab.com/nicolalandro/obj2html/-/raw/main/test/assets/model.obj)
import streamlit as st
import streamlit.components.v1 as components
from obj2html import obj2html
html_string = obj2html("model.obj", html_elements_only=True)
components.html(html_string)
with open("model.obj") as f:
st.download_button('Download model.obj', f, file_name="download_name.obj")
```
![](imgs/streamlit_example.png)
2021-11-13 06:55:57 -07:00
2021-11-13 06:26:55 -07:00
## Features
2021-11-13 06:57:56 -07:00
2021-11-13 07:00:47 -07:00
- [x] .obj files support
2021-11-13 08:28:57 -07:00
- [x] pipy delivery
- [x] guide for notebook
- [x] pypi doc add image
2021-11-14 07:41:53 -07:00
- [x] edit html positions and other 3D params
2021-11-20 07:55:45 -07:00
- [x] add param for streamlit
2021-11-21 06:03:30 -07:00
- [x] document param for streamlit
2021-11-13 08:28:57 -07:00
- [ ] dist wheel
2021-11-13 06:57:56 -07:00
- [ ] load three.js as static file
- [ ] .mat files support
2021-11-13 06:26:55 -07:00
2021-11-13 06:55:57 -07:00
# Dev
2021-11-13 07:33:54 -07:00
* run test
2021-11-13 06:55:57 -07:00
```
python3.8 -m unittest discover
2021-11-13 07:33:54 -07:00
```
* run test with coverage
```
2021-11-13 06:55:57 -07:00
pip install coverage
python3.8 -m coverage run --source=src -m unittest discover
python3.8 -m coverage report -m
```
2021-11-13 07:33:54 -07:00
* deploy pipy
```
2021-11-13 08:28:57 -07:00
pip install twine
2021-11-13 08:04:16 -07:00
rm -rf dist
2021-11-13 07:33:54 -07:00
python setup.py sdist
2021-11-13 08:04:16 -07:00
twine check dist/*
2021-11-13 07:33:54 -07:00
twine upload dist/*
2021-11-13 08:28:57 -07:00
# in one line
2021-11-13 07:33:54 -07:00
```
2021-11-13 06:55:57 -07:00
2021-11-13 06:26:55 -07:00
# References
In this chapter I add at least a link for each of the knowledge needed for develop this project.
2021-11-14 08:02:01 -07:00
* [python ](https://www.python.org/ ): programming language for develop the tool
* [HTML ](https://www.w3schools.com/html/ ): markup language for the output file generated by the tool
* [JavaScript ](https://www.w3schools.com/js/ ): programming language used into the HTML for logic implementation
* [mustache ](https://www.elated.com/easy-html-templates-with-mustache/ ): sintax for dynamic templating ( exist [pymustache ](https://github.com/lotabout/pymustache ) but I use a custom function with same sintax because of it does not work into js inside html)
* [git ](https://git-scm.com/doc ): tool used for version control
2021-11-13 07:18:04 -07:00
* [how to write a setup.py ](https://medium.com/@joel.barmettler/how-to-upload-your-python-package-to-pypi-65edc5fe9c56 )
2021-11-14 08:02:01 -07:00
* [unittest ](https://docs.python.org/3/library/unittest.html ): the used python framework for test automation
* [coverage.py ](https://coverage.readthedocs.io/en/6.1.2/ ): lib used for code coverage computation
* [gitlab ci/cd ](https://docs.gitlab.com/ee/ci/quick_start/ ): for run the integration test
2021-11-14 08:09:05 -07:00
* [gitlab ci/cd display coverage ](https://www.activestate.com/blog/how-to-set-up-ci-cd-for-python-on-gitlab/ ): how to display code coverage into badge
2021-11-14 08:02:01 -07:00
* [three.js ](https://threejsfundamentals.org/ ): js lib to open and visualize 3D model
2021-11-14 08:09:05 -07:00
* [Shields.io ](https://shields.io/ ): for custom static badges like pypi