obj2html

Create an html with three.js that contains the given .obj file.

Downloads
106
Stars
0
Committers
2

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.

Install with pip install obj2html and use with obj2html('model.obj', 'index.html')

! pip install obj2html
! wget https://gitlab.com/nicolalandro/obj2html/-/raw/main/test/assets/model.obj
from obj2html import obj2html
from IPython.display import display, HTML

obj2html('model.obj', 'index.html')

display(HTML('index.html'))
# 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")

Features

  • .obj files support
  • pipy delivery
  • guide for notebook
  • pypi doc add image
  • edit html positions and other 3D params
  • add param for streamlit
  • document param for streamlit
  • auto center and fit the 3D object on the camera view
  • dist wheel for pypi
  • load three.js as static file
  • .mat files support

Dev

  • run test
python3.8 -m unittest discover
  • run test with coverage
pip install coverage
python3.8 -m coverage run --source=src -m unittest discover
python3.8 -m coverage report -m
  • deploy pipy
pip install twine

rm -rf dist

python setup.py sdist
twine check dist/*

twine upload dist/*

# in one line

References

In this chapter I add at least a link for each of the knowledge needed for develop this project.

  • python: programming language for develop the tool
  • HTML: markup language for the output file generated by the tool
  • JavaScript: programming language used into the HTML for logic implementation
  • mustache: sintax for dynamic templating ( exist pymustache but I use a custom function with same sintax because of it does not work into js inside html)
  • git: tool used for version control
  • how to write a setup.py
  • unittest: the used python framework for test automation
  • coverage.py: lib used for code coverage computation
  • gitlab ci/cd: for run the integration test
  • gitlab ci/cd display coverage: how to display code coverage into badge
  • three.js: js lib to open and visualize 3D model
  • Shields.io: for custom static badges like pypi
Package Rankings
Top 21.06% on Pypi.org
Badges
Extracted from project README
pipeline status coverage report License: MIT pypi package pypi downloads numbers Open In Colab Open Streamlit in HuggingFace spaces