Skip to main content

embed4d

PyPI Open In Colab PyPI - License PRs Welcome Open in Spaces

Embed 4D (3D + time) — lightweight GLB/GLTF/FBX animation viewer with:

  • Python package: embed4d (import as embed4d)
  • Jupyter notebook integration for inline 3D model viewing
  • Embeddable HTML viewer for Gradio or any web UI
  • FastAPI server for serving models over HTTP
  • Static HTML app for drag‑and‑drop viewing of models

1. Python Installation

From PyPI

pip install embed4d

From source (this repo)

Inside the repo root:

# Using pip
pip install -e .

# Or using uv (faster, recommended for dev)
uv pip install -e .

1. Python API

The core helpers live in embed4d.viewer and are re‑exported at the package root.

from embed4d import open_viewer_webview

open_viewer_webview("motion.glb")

2. 🤗 Gradio integration Open in Spaces

The file examples/demo_gradio.py contains a small demo that compares:

  • A custom HTML viewer using gr.HTML
  • Gradio’s built‑in gr.Model3D component

You typically want to use iframe_srcdoc_html or model3d_viewer from your own Gradio app:

import gradio as gr
from embed4d import model3d_viewer

with gr.Blocks() as demo:
    file_input = gr.File(file_types=[".glb"], label="Select GLB File")
    viewer_output = gr.HTML()

    file_input.change(
        lambda file: model3d_viewer(file.name if file else None),
        inputs=file_input,
        outputs=viewer_output,
    )

demo.launch()

3. FastAPI Server

The package includes a FastAPI server for serving the 3D viewer via HTTP. This is useful for:

  • Serving models over a network
  • Embedding the viewer in web applications
  • Sharing models with others via a URL

Python API

from embed4d.viewer_server import launch

# Launch server with automatic port selection
url = launch()
print(f"Viewer available at: {url}")

# Launch server on a specific port
url = launch(port=8080)

# Launch server with a model file
url = launch(port=8080, model_file="motion.glb")

Command Line Interface

You can also run the server directly from the command line:

# Start server with automatic port selection
python -m embed4d.viewer_server

# Start server on a specific port
python -m embed4d.viewer_server --port 8080

# Start server with a model file
python -m embed4d.viewer_server --port 8080 --model motion.glb

The server provides two endpoints:

  • GET / - Returns the HTML viewer (with embedded model if provided)
  • GET /model - Returns the GLB model file (if provided)

The server runs in a background thread and returns the URL where the viewer is accessible.


4. Inside Jupyter Notebook or Colab Colab

Display 3D GLB/GLTF models directly in Jupyter notebook cells using notebook_viewer. Uses the full embed4d template (Three.js, upload UI, FBX, animation controls) and works in Jupyter and Colab. See examples/demo_notebook.ipynb for a runnable notebook.

Basic Usage

from embed4d import notebook_viewer

notebook_viewer("path/to/model.glb")
notebook_viewer("model.glb", height=800)

# Empty viewer with upload/drag-and-drop
notebook_viewer()

Requirements

  • IPython must be installed: pip install ipython
  • Works in Jupyter Notebook, JupyterLab, and other IPython-compatible environments
  • Requires a modern browser with WebGL support

Features

  • Inline rendering: Viewer displays directly in notebook cells
  • File embedding: GLB files are base64-encoded and embedded in the HTML
  • Interactive controls: Full keyboard shortcuts and mouse controls
  • Animation playback: Supports animated GLB files with timeline controls

5. Static HTML viewer

The package ships a pre‑built Three.js viewer template at:

  • embed4d/templates/index.html

This is the same HTML that’s used for:

  • get_viewer_html and iframe_srcdoc_html
  • Any exported HTML file produced by the CLI

More examples

In examples/ you’ll find: demo_gradio.py, demo_notebook.ipynb, demo_webview.py, demo_server.py. See examples/README.md for how to run them.

Running tests

pytest
# or, with uv:
uv run pytest

Linting / formatting

This project uses ruff via config in pyproject.toml. If you have ruff installed:

ruff check .

(CI will run linting for you; see .github/workflows/.)


6. Working on the HTML/Three.js viewer

The main viewer template is:

  • embed4d/templates/index.html

It is self‑contained:

  • Uses CDN Three.js + GLTFLoader
  • Supports drag & drop .glb/.gltf
  • Provides keyboard shortcuts, skeleton toggle, ground plane, etc.

Workflow:

  1. Edit the HTML/JS in embed4d/templates/index.html.
  2. Run the Python tests to ensure the template still contains the {{GLB_BASE64}} placeholder and that the iframe generation works.
  3. Rebuild / re‑publish the package as needed.

Metadata

Release files for embed4d 0.0.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for embed4d 0.0.7
File Size Uploaded Provenance Actions
embed4d-0.0.7.tar.gz 35.8 kB With provenance Details for embed4d-0.0.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for embed4d 0.0.7
File Interpreter ABI Platform Actions
embed4d-0.0.7-py3-none-any.whl Python 3 none any Details for embed4d-0.0.7-py3-none-any.whl

Total release size: 62.4 kB

Release files / embed4d-0.0.7.tar.gz

Download URL embed4d-0.0.7.tar.gz
Size 35.8 kB
Tags Source
SHA-256 checksum
How to use checksums
9c46e4898ce586827c9b0722b0ffc865f9bd6aee5622f330d33aed912f81e7ac
BLAKE2b-256 checksum
How to use checksums
31aa9b0b8956679d360deb6772bdabc1114c79f34d8ac74005bb39d456fb61eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 17, 2026.

Transparency log

Release files / embed4d-0.0.7-py3-none-any.whl

Download URL embed4d-0.0.7-py3-none-any.whl
Size 26.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
92e2bf52d5e2f2c25ccbec77c908236efbb918b7b1d9ae951d2e083d545474c6
BLAKE2b-256 checksum
How to use checksums
6d8f02bc21a54f072cb02b9f49d90e569238a9f5a3b7ec387f783b6c4c626d04
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 17, 2026.

Transparency log

Security for embed4d 0.0.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for embed4d-0.0.7.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 17, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page