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 BadgeHugging Face Spaces

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

Installation

pip install gradio_sync3dcompare

Usage

from pathlib import Path

import gradio as gr

from gradio_sync3dcompare import Sync3DCompare


ROOT = Path(__file__).resolve().parent
SAMPLE_DIR = (ROOT / "demo" / "sample_data").resolve()
MESH_A = SAMPLE_DIR / "mesh_a.glb"
MESH_B = SAMPLE_DIR / "mesh_b.glb"
POINT_SIZE = 0.5
DEFAULT_ZOOM = 1
MIN_ZOOM = 0.5
MAX_ZOOM = 16.0


def load_comparison():
    return [
        {"name": "Mesh A", "path": str(MESH_A)},
        {"name": "Mesh B", "path": str(MESH_B)},
    ]


with gr.Blocks(title="Synchronized GLB Comparison") as demo:
    gr.Markdown("# Synchronized GLB Comparison")
    gr.Markdown(
        "Click the button to load two GLB files into a side-by-side viewer with synchronized orbit, zoom, and pan."
    )

    load_button = gr.Button("Load Comparison")
    viewer = Sync3DCompare(
        value=[],
        label="3D Comparison",
        render_mode="points",
        sync_camera=True,
        point_size=POINT_SIZE,
        default_zoom=DEFAULT_ZOOM,
        min_zoom=MIN_ZOOM,
        max_zoom=MAX_ZOOM,
        height=500,
        num_views=2,
    )

    load_button.click(fn=load_comparison, outputs=viewer)


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

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.7.tar.gz (730.8 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.7-py3-none-any.whl (308.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gradio_sync3dcompare-0.0.7.tar.gz
  • Upload date:
  • Size: 730.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for gradio_sync3dcompare-0.0.7.tar.gz
Algorithm Hash digest
SHA256 21553b0dd0cc01c6b7d7ef4e63bd62d16a50cbc9044fc3b996c3ad64ef58be99
MD5 40f858bb7dbb5fd0e70fc5cbcf8a5d8e
BLAKE2b-256 4bd6e416f06b14e5bdf9b095ab38b5ab16202276debd21153f57e31b4226777c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for gradio_sync3dcompare-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 4a889f8dad996a74388d2190e776c233a851bb5e40b5ec4426bf5183ccf81092
MD5 e1adf3d533ba3771b8354e8254a8381b
BLAKE2b-256 736fbd0e396e4cc141bfda5291ae327e746ab390fc3da40befd9d37ea4124031

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