Skip to content

Repository files navigation

polyrender

Three Fiber–based anywidget for 2.5D polygons: preprocess stacked 2D outlines (per cell_id and ZIndex), build triangulated meshes, export spatial GLB tiles, and view them in the browser with a local tile server and WebGL widget.

polyrender viewer showing colorful 3D cell meshes

Documentation (Zensical): ckmah.github.io/polyrender

Requirements

  • Python 3.12+
  • uv recommended (see pyproject.toml for dependencies)

Install

From the repository root:

uv sync

Optional extras:

# test dependencies
uv sync --extra test

# docs tooling
uv sync --extra docs

# local development group (pytest + zensical)
uv sync --group dev

Quick start (marimo)

uv run marimo edit quickstart.py

Open in molab

Usage

import polyrender as po

tiles_info = po.meshify(gdf)  # default cache: ./.polyrender/<hash>/
po.plot(gdf)  # meshifies from cache if needed; wireframe / opacity / BG in the viewer UI
  • meshify: preprocess a GeoDataFrame (cell_id, ZIndex, geometry), write tiles/ and tiles.json under .polyrender/<content hash>/ by default (override with out_dir=...). Use smooth=False for no Taubin smoothing, use_cache=False to force a rebuild.
  • plot: calls meshify when needed, starts or reuses a local tile server, and returns a marimo anywidget viewer. Wireframe, opacity, and background are adjusted in the widget toolbar, not via Python.

Full demo (development notebook)

The longer example is dev/full_demo.py (a marimo app for development/benchmarking):

uv run marimo edit dev/full_demo.py

Sample data

The repository tracks sample_data/liver_crop_sample.parquet, a small subset (~50 cells) for CI and quick starts. A full liver_crop.parquet and other large exports can live in sample_data/ locally; they are gitignored. To regenerate the subset from a local full file:

uv run python scripts/make_liver_subset.py

Development

The Python package lives in the polyrender/ directory. Optional: install gltfpack on your PATH for smaller GLB files (compression is enabled inside meshify).

Repository

github.com/ckmah/polyrender

To publish pre-rendered molab sessions, run from the repo root: uvx marimo export session quickstart.py (and similarly for dev/full_demo.py if desired).

About

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages