SVG3D was designed to bridge the gap between raytraced rendering engines like Blender and plotting tools like matplotlib and plotly. Common computer graphics techniques and models have been adapted to work within the counstraints of vector art, an approach that enables users to generate compact, scalable images with realistic shading.

A reimagining of the excellent original library with the same name, this version has many new features, a more general interface, and a somewhat different scope. We aim to streamline the process of rendering scenes of geometries for scientific publications, although the libary is useful for a diverse array of applications.

Many thanks to the Keenan 3D Model repository and the Georgia Tech Large Models Archive for the models rendered in the header image.

CI ReadTheDocs

Installation

svg3d is available on PyPI, and can be easily installed from there:

pip install svg3d

The package can also be built from source:

# Clone the repository
git clone https://github.com/janbridley/svg3d.git
cd svg3d

# Install to your python environment!
python -m pip install .

Quickstart Example

svg3d provides convenience View options for standard rendering perspectives - isometric, dimetric, and trimetric. Shapes can be easily created from coxeter objects, or from raw mesh data.

from coxeter.families import ArchimedeanFamily
import svg3d

style = {
    "fill": "#00B2A6",
    "fill_opacity": "0.85",
    "stroke": "black",
    "stroke_linejoin": "round",
    "stroke_width": "0.005",
}

truncated_cube = ArchimedeanFamily.get_shape("Truncated Cube")

scene = [
    svg3d.Mesh.from_coxeter(
        truncated_cube,
        shader=svg3d.shaders.DiffuseShader.from_style_dict(style)
    )
]

# Convenience views: isometric, dimetric, and trimetric
iso = svg3d.View.isometric(scene, fov=1.0)
dim = svg3d.View.dimetric(scene, fov=1.0)
tri = svg3d.View.trimetric(scene, fov=1.0)

for view, view_type in zip([iso, dim, tri], ["iso", "dim", "tri"]):
    svg3d.Engine([view]).render(f"{view_type}.svg")

Isometric

Dimetric

Trimetric

_images/iso.svg _images/dim.svg _images/tri.svg