Skip to main content

Synchronized side-by-side 3D comparison viewer for Gradio — supports PLY and GLB files with shared camera control.

Project description

gradio_sync3dcompare

PyPI - Version Static Badge

Synchronized side-by-side 3D comparison viewer for Gradio — supports PLY and GLB files with shared camera control.

Installation

pip install gradio_sync3dcompare

Usage

import gradio as gr
from gradio_sync3dcompare import Sync3DCompare
import os

SAMPLE_DIR = os.path.join(os.path.dirname(__file__), "sample_data")

def get_path(filename):
    return os.path.join(SAMPLE_DIR, filename)


with gr.Blocks(title="Sync3DCompare Demo") as demo:
    gr.Markdown("# Sync3DCompare — Synchronized 3D Comparison Viewer")
    gr.Markdown(
        "Compare 3D reconstruction outputs side-by-side with synchronized orbit, pan, and zoom. "
        "Rotate one view and all others follow."
    )

    with gr.Tabs():

        # --- Tab A: PLY comparison ---
        with gr.TabItem("PLY Comparison"):
            gr.Markdown("### Three PLY point clouds compared side-by-side")
            Sync3DCompare(
                label="PLY Comparison",
                value=[
                    {
                        "name": "Ground Truth",
                        "path": get_path("ground_truth.ply"),
                        "type": "ply",
                        "color": [80, 200, 120],
                    },
                    {
                        "name": "Method A",
                        "path": get_path("method_a.ply"),
                        "type": "ply",
                        "color": [100, 160, 240],
                    },
                    {
                        "name": "Method B",
                        "path": get_path("method_b.ply"),
                        "type": "ply",
                        "color": [240, 140, 80],
                    },
                ],
                render_mode="points",
                sync_camera=True,
                point_size=2.0,
                height=500,
            )

        # --- Tab B: GLB comparison ---
        with gr.TabItem("GLB Comparison"):
            gr.Markdown("### Two GLB mesh outputs compared in native mode")
            Sync3DCompare(
                label="GLB Comparison",
                value=[
                    {
                        "name": "Mesh A (detailed)",
                        "path": get_path("mesh_a.glb"),
                        "type": "glb",
                    },
                    {
                        "name": "Mesh B (coarse)",
                        "path": get_path("mesh_b.glb"),
                        "type": "glb",
                    },
                ],
                render_mode="native",
                sync_camera=True,
                point_size=2.0,
                height=500,
            )

        # --- Tab C: Mixed PLY + GLB ---
        with gr.TabItem("Mixed Format (Points Mode)"):
            gr.Markdown(
                "### PLY + GLB compared in `points` mode — GLB is sampled to point cloud for fair comparison"
            )
            Sync3DCompare(
                label="Mixed Format Comparison",
                value=[
                    {
                        "name": "PLY Point Cloud",
                        "path": get_path("ground_truth.ply"),
                        "type": "ply",
                        "color": [80, 200, 120],
                    },
                    {
                        "name": "GLB as Points",
                        "path": get_path("mesh_a.glb"),
                        "type": "glb",
                    },
                ],
                render_mode="points",
                sync_camera=True,
                point_size=3.0,
                height=500,
            )


if __name__ == "__main__":
    demo.launch()

Sync3DCompare

Initialization

name type default description
value
list[dict]| None
value = None None
label
str| None
value = "3D Comparison" None
render_mode
"points"| "native"
value = "points" None
sync_camera
bool
value = True None
point_size
float
value = 2.0 None
height
int
value = 500 None
num_views
int
value = 2 None
interactive
bool
value = True None
visible
bool
value = True None
elem_id
str| None
value = None None
elem_classes
list[str]| str| None
value = None None
render
bool
value = True None

Events

name description
change

User function

The impact on the users predict function varies depending on whether the component is used as an input or output for an event (or both).

  • When used as an Input, the component only impacts the input signature of the user function.
  • When used as an output, the component only impacts the return signature of the user function.

The code snippet below is accurate in cases where the component is used as both an input and an output.

  • As input: Should return, the output data received by the component from the user's function in the backend.
def predict(
    value: Unknown
) -> list[dict]| None:
    return value

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

gradio_sync3dcompare-0.0.8.tar.gz (694.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gradio_sync3dcompare-0.0.8-py3-none-any.whl (303.6 kB view details)

Uploaded Python 3

File details

Details for the file gradio_sync3dcompare-0.0.8.tar.gz.

File metadata

  • Download URL: gradio_sync3dcompare-0.0.8.tar.gz
  • Upload date:
  • Size: 694.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for gradio_sync3dcompare-0.0.8.tar.gz
Algorithm Hash digest
SHA256 aa8b1cb4b55df00dee73134b228564256a062b5f54ebcbb5e7c5926a848873c0
MD5 fcc57a3433257df9869b19e8c7d31b5a
BLAKE2b-256 c58c0a9d01cb39d1de54ef79df5047e4e89d2cf12771dab5ba7b444dcd8d3cfe

See more details on using hashes here.

File details

Details for the file gradio_sync3dcompare-0.0.8-py3-none-any.whl.

File metadata

File hashes

Hashes for gradio_sync3dcompare-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 5482189edba57161d2f08cc5e46c734d326d742ca1d38b9d74f437ce1a1ad772
MD5 3c0168feff649571891a2f5e6d26bc54
BLAKE2b-256 26d9aa0af9e8756e1477aef07c54aaacc1e10444ec7d85cca412e366a652eecd

See more details on using hashes here.

Supported by

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