Skip to main content

Some tools for getting Wavefront OBJ files into a Plotly Dash 3dmesh graph

Project description

Import a Wavefront OBJ file into a plot.ly Dash 3dMesh graph:

pip install git+https://github.com/aegis1980/dash-obj-in-3dmesh.git

Some notes:

File locations

Put your wavefront obj & mtl file in 'data/obj' directory (this is the default). Alternatively pass a path to:

import_geometry(obj_names : List[str], path = _config.GEOMETRY_DIR)

Geometry

  • Only triangulated meshes supported (i.e 3 vertices per face). Sort this out in your modelling software (e.g. Rhino)
  • Textures, normals, groups are all ignored - only vertices, faces, materials and object names are parsed and passed to Dash graph as mesh data.

Materials

Only basic materials supported in mtl file: e.g:

newmtl diffuse_Green
Ka 0.0000 0.0000 0.0000
Kd 0.0000 1.0000 0.0000
Ks 1.0000 1.0000 1.0000
Tf 0.0000 0.0000 0.0000
d 1.0000
Ns 0.0000

Only the value for Kd is used - so set this as your colour (in modelling software)

Code example

import dash
from dash_obj_in_3dmesh import geometry_tools, wav_obj


model_name = "test" #.obj & .mtl files in data/obj


axis_template = {
    "showbackground": False,
    "visible" : False
}

plot_layout = {
    "title": "",
    "margin": {"t": 0, "b": 0, "l": 0, "r": 0},
    "font": {"size": 12, "color": "white"},
    "showlegend": False,
    'uirevision':'same_all_the_time', #this keeps camera position etc the same when data changes.
    "scene": {
        "xaxis": axis_template,
        "yaxis": axis_template,
        "zaxis": axis_template,
        "aspectmode" : "data",
        "camera": {"eye": {"x": 1.25, "y": 1.25, "z": 1.25}},
        "annotations": [],
    },
}

layout = return html.Div([dcc.Graph(
                        id="graph",
                        figure={
                            "data": geometry_tools.import_geometry([model_name]),
                            "layout": plot_layout,
                        },
                        config={"scrollZoom": True}, # activates wheel thingy on mouse to zoom and wotnot
                    )])

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

dash-obj-in-3dmesh-0.3.1.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

dash_obj_in_3dmesh-0.3.1-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file dash-obj-in-3dmesh-0.3.1.tar.gz.

File metadata

  • Download URL: dash-obj-in-3dmesh-0.3.1.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.8.0

File hashes

Hashes for dash-obj-in-3dmesh-0.3.1.tar.gz
Algorithm Hash digest
SHA256 647005b5b62cfec780a1966cbc2a4e507577b6d5ad73d6590a672600c1126cd8
MD5 942e8b64aeba6f9114adedfbeb7b07b7
BLAKE2b-256 a8414bf97113192c62f85ebfb6cda4057424a4fc29896bc5f18a4be87b7a6370

See more details on using hashes here.

File details

Details for the file dash_obj_in_3dmesh-0.3.1-py3-none-any.whl.

File metadata

  • Download URL: dash_obj_in_3dmesh-0.3.1-py3-none-any.whl
  • Upload date:
  • Size: 14.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.8.0

File hashes

Hashes for dash_obj_in_3dmesh-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 457d93724c4d973a98339fc6e494ab50b9eeeafd96c480560ba87f6a818c66a4
MD5 277c5ad03d50fdabb4bea63db8b3c6ca
BLAKE2b-256 9a2d27a7e7e2127a3d981edcf422573fe0813f3d24bffecf8ce940ca4daafc65

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page