Embed 4D (3D + time): lightweight GLB/GLTF/FBX animation viewer (standalone HTML + Python helpers for embedding/export).
Project description
embed4d
Embed 4D (3D + time) — lightweight GLB/GLTF/FBX animation viewer with:
- Python package:
embed4d(import asembed4d) - 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 
The file examples/demo_gradio.py contains a small demo that compares:
- A custom HTML viewer using
gr.HTML - Gradio’s built‑in
gr.Model3Dcomponent
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 
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_htmlandiframe_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:
- Edit the HTML/JS in
embed4d/templates/index.html. - Run the Python tests to ensure the template still contains the
{{GLB_BASE64}}placeholder and that the iframe generation works. - Rebuild / re‑publish the package as needed.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file embed4d-0.0.7.tar.gz.
File metadata
- Download URL: embed4d-0.0.7.tar.gz
- Upload date:
- Size: 35.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c46e4898ce586827c9b0722b0ffc865f9bd6aee5622f330d33aed912f81e7ac
|
|
| MD5 |
21439031c794229bf7a180de6716209a
|
|
| BLAKE2b-256 |
31aa9b0b8956679d360deb6772bdabc1114c79f34d8ac74005bb39d456fb61eb
|
Provenance
The following attestation bundles were made for embed4d-0.0.7.tar.gz:
Publisher:
tag_release_publish.yml on myolab/embed4d
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
embed4d-0.0.7.tar.gz -
Subject digest:
9c46e4898ce586827c9b0722b0ffc865f9bd6aee5622f330d33aed912f81e7ac - Sigstore transparency entry: 960247193
- Sigstore integration time:
-
Permalink:
myolab/embed4d@873f23e7bc73a3235c75b1b9a5de568d997e9d21 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/myolab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
tag_release_publish.yml@873f23e7bc73a3235c75b1b9a5de568d997e9d21 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file embed4d-0.0.7-py3-none-any.whl.
File metadata
- Download URL: embed4d-0.0.7-py3-none-any.whl
- Upload date:
- Size: 26.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
92e2bf52d5e2f2c25ccbec77c908236efbb918b7b1d9ae951d2e083d545474c6
|
|
| MD5 |
9bbd8814cc7056ed8479bd846947e865
|
|
| BLAKE2b-256 |
6d8f02bc21a54f072cb02b9f49d90e569238a9f5a3b7ec387f783b6c4c626d04
|
Provenance
The following attestation bundles were made for embed4d-0.0.7-py3-none-any.whl:
Publisher:
tag_release_publish.yml on myolab/embed4d
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
embed4d-0.0.7-py3-none-any.whl -
Subject digest:
92e2bf52d5e2f2c25ccbec77c908236efbb918b7b1d9ae951d2e083d545474c6 - Sigstore transparency entry: 960247261
- Sigstore integration time:
-
Permalink:
myolab/embed4d@873f23e7bc73a3235c75b1b9a5de568d997e9d21 -
Branch / Tag:
refs/heads/main - Owner: https://github.com/myolab
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
tag_release_publish.yml@873f23e7bc73a3235c75b1b9a5de568d997e9d21 -
Trigger Event:
workflow_dispatch
-
Statement type: