Skip to content

Commit

Permalink
Visual adjustments (initial pass) (nerfstudio-project#134)
Browse files Browse the repository at this point in the history
* Alignment

* Frontend pass

* README strip for publish action

* Add mising target="_blank"

* Remove test line
  • Loading branch information
brentyi authored Nov 22, 2023
1 parent a870e9a commit 0a020fb
Show file tree
Hide file tree
Showing 26 changed files with 428 additions and 146 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ jobs:
pip install build twine
# Build client files.
python -c "import viser; viser.ViserServer()"
- name: Strip unsupported tags in README
run: |
sed -i '/<!-- pypi-strip -->/,/<!-- \/pypi-strip -->/d' README.md
- name: Build and publish
env:
PYPI_USERNAME: ${{ secrets.PYPI_USERNAME }}
Expand Down
77 changes: 48 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,44 +1,62 @@
<h1>
viser
</h1>

**`pip install viser`** &nbsp;&nbsp;&bull;&nbsp;&nbsp; **[
[API Reference](https://nerfstudio-project.github.io/viser) ]**

![pyright](https://github.com/nerfstudio-project/viser/workflows/pyright/badge.svg)
![mypy](https://github.com/nerfstudio-project/viser/workflows/mypy/badge.svg)
![typescript](https://github.com/nerfstudio-project/viser/workflows/typescript-compile/badge.svg)
[![pypi](https://img.shields.io/pypi/pyversions/viser)](https://pypi.org/project/viser)

---

`viser` is a library for interactive 3D visualization + Python, inspired by
<p align="center">
<!--
Note that this README will be used for both GitHub and PyPI.
We therefore:
- Keep all image URLs absolute.
- In the GitHub action we use for publishing, strip some HTML tags that aren't supported by PyPI.
-->
<!-- pypi-strip -->
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://viser.studio/_static/viser_banner_dark.svg" />
<!-- /pypi-strip -->
<img alt="tyro logo" src="https://viser.studio/_static/viser_banner.svg" width="200px" />
<!-- pypi-strip -->
</picture>
<!-- /pypi-strip -->

</p>

<br />

<p align="center">
<strong><code>pip install viser</code></strong>
&nbsp;&nbsp;&bull;&nbsp;&nbsp;
<strong><a href="https://viser.studio">Documentation</a></strong>
</p>

<p align="center">
<img alt="pyright" src="https://github.com/nerfstudio-project/viser/workflows/pyright/badge.svg?branch=main" />
<img alt="mypy" src="https://github.com/nerfstudio-project/viser/workflows/mypy/badge.svg?branch=main" />
<img alt="typescript-compile" src="https://github.com/nerfstudio-project/viser/workflows/typescript-compile/badge.svg?branch=main" />
<a href="https://pypi.org/project/viser/">
<img alt="codecov" src="https://img.shields.io/pypi/pyversions/viser" />
</a>
</p>

**`viser`** is a library for interactive 3D visualization + Python, inspired by
tools like [Pangolin](https://github.com/stevenlovegrove/Pangolin),
[rviz](https://wiki.ros.org/rviz/),
[meshcat](https://github.com/rdeits/meshcat), and
[Gradio](https://github.com/gradio-app/gradio).
[Gradio](https://github.com/gradio-app/gradio). It's designed to support
applications in 3D vision and robotics.

As a standalone visualization tool, `viser` features include:

- Web interface for easy use on remote machines.
- Python API for sending 3D primitives to the browser.
- Python-configurable inputs: buttons, checkboxes, text inputs, sliders,
dropdowns, gizmos.
- Python API for visualizing 3D primitives in a web browser.
- Python-configurable GUI elements: buttons, checkboxes, text inputs, sliders,
dropdowns, and more.
- A [meshcat](https://github.com/rdeits/meshcat) and
[tf](http://wiki.ros.org/tf2)-inspired coordinate frame tree.

The `viser.infra` backend can also be used to build custom web applications
(example:
[the original Nerfstudio viewer](https://github.com/nerfstudio-project/nerfstudio)).
It supports:
The `viser.infra` backend can also be used to build custom web applications. It
supports:

- Websocket / HTTP server management, on a shared port.
- Asynchronous server/client communication infrastructure.
- Client state persistence logic.
- Typed serialization; synchronization between Python dataclass and TypeScript
interfaces.


## Installation

You can install `viser` with `pip`:
Expand Down Expand Up @@ -66,8 +84,7 @@ python ./examples/02_gui.py
After an example script is running, you can connect by navigating to the printed
URL (default: `http://localhost:8080`).

See also: our [development docs](https://nerfstudio-project.github.io/viser/development/).

See also: our [development docs](https://viser.studio/development/).

## Examples

Expand All @@ -81,8 +98,10 @@ Source: `./examples/07_record3d_visualizer.py`

https://github.com/nerfstudio-project/viser/assets/6992947/c51b4871-6cc8-4987-8751-2bf186bcb1ae

Source: [WangFeng18/3d-gaussian-splatting](https://github.com/WangFeng18/3d-gaussian-splatting)
and [heheyas/gaussian_splatting_3d](https://github.com/heheyas/gaussian_splatting_3d).
Source:
[WangFeng18/3d-gaussian-splatting](https://github.com/WangFeng18/3d-gaussian-splatting)
and
[heheyas/gaussian_splatting_3d](https://github.com/heheyas/gaussian_splatting_3d).

**SMPLX visualizer**

Expand Down
2 changes: 1 addition & 1 deletion docs/source/_static/css/custom.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
img.sidebar-logo {
width: 3em;
width: 100%;
margin: 1em 0 0 0;
}
.sidebar-brand-text {
Expand Down
1 change: 1 addition & 0 deletions docs/source/_static/viser_banner.svg
1 change: 1 addition & 0 deletions docs/source/_static/viser_banner_dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@
"class": "",
},
],
"light_logo": "viser.svg",
"dark_logo": "viser.svg",
"light_logo": "viser_banner.svg",
"dark_logo": "viser_banner_dark.svg",
}

# Pull documentation types from hints
Expand Down
3 changes: 2 additions & 1 deletion docs/source/examples/08_smplx_visualizer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ parameters to run this script:
share: bool = False,
) -> None:
server = viser.ViserServer(share=share)
server.configure_theme(control_layout="collapsible", dark_mode=True)
server.configure_theme(control_layout="collapsible")
model = smplx.create(
model_path=str(model_path),
model_type=model_type,
Expand Down Expand Up @@ -142,6 +142,7 @@ parameters to run this script:
# GUI elements: mesh settings + visibility.
with tab_group.add_tab("View", viser.Icon.VIEWFINDER):
gui_rgb = server.add_gui_rgb("Color", initial_value=(90, 200, 255))
gui_rgb_text = server.add_gui_text("Color", "")
gui_wireframe = server.add_gui_checkbox("Wireframe", initial_value=False)
gui_show_controls = server.add_gui_checkbox("Handles", initial_value=False)
Expand Down
4 changes: 3 additions & 1 deletion docs/source/examples/18_splines.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,15 @@ Make a ball with some random splines.
def main() -> None:
server = viser.ViserServer()
for i in range(50):
for i in range(10):
positions = onp.random.normal(size=(30, 3)) * 3.0
server.add_spline_catmull_rom(
f"/catmull_{i}",
positions,
tension=0.5,
line_width=3.0,
color=onp.random.uniform(size=3),
segments=100,
)
control_points = onp.random.normal(size=(30 * 2 - 2, 3)) * 3.0
Expand All @@ -39,6 +40,7 @@ Make a ball with some random splines.
control_points,
line_width=3.0,
color=onp.random.uniform(size=3),
segments=100,
)
while True:
Expand Down
7 changes: 7 additions & 0 deletions docs/source/extras.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Extras

<!-- prettier-ignore-start -->

.. automodule:: viser.extras

<!-- prettier-ignore-end -->
25 changes: 13 additions & 12 deletions docs/source/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@

|mypy| |nbsp| |pyright| |nbsp| |typescript| |nbsp| |versions|

`viser` is a library for interactive 3D visualization + Python, inspired by
**viser** is a library for interactive 3D visualization + Python, inspired by
tools like [Pangolin](https://github.com/stevenlovegrove/Pangolin),
[rviz](https://wiki.ros.org/rviz/), and
[meshcat](https://github.com/rdeits/meshcat).
[rviz](https://wiki.ros.org/rviz/),
[meshcat](https://github.com/rdeits/meshcat), and
[Gradio](https://github.com/gradio-app/gradio). It's designed to support
applications in 3D vision and robotics.

As a standalone visualization tool, `viser` features include:

- Web interface for easy use on remote machines.
- Python API for sending 3D primitives to the browser.
- Python-configurable inputs: buttons, checkboxes, text inputs, sliders,
dropdowns, gizmos.
- Support for multiple panels and view-synchronized connections.
- Python API for visualizing 3D primitives in a web browser.
- Python-configurable GUI elements: buttons, checkboxes, text inputs, sliders,
dropdowns, and more.
- A [meshcat](https://github.com/rdeits/meshcat) and
[tf](http://wiki.ros.org/tf2)-inspired coordinate frame tree.

The `viser.infra` backend can also be used to build custom web applications
(example:
[the Nerfstudio viewer](https://github.com/nerfstudio-project/nerfstudio)). It
The `viser.infra` backend can also be used to build custom web applications. It
supports:

- Websocket / HTTP server management, on a shared port.
Expand All @@ -39,7 +39,7 @@ pip install -e .

# Run an example.
pip install -e .[examples]
python ./examples/4_gui.py
python ./examples/02_gui.py
```

After an example script is running, you can connect by navigating to the printed
Expand Down Expand Up @@ -78,6 +78,7 @@ URL (default: `http://localhost:8080`).

./infrastructure.md
./transforms.md
./extras.md

.. toctree::
:caption: Examples
Expand Down
2 changes: 1 addition & 1 deletion examples/08_smplx_visualizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def main(
share: bool = False,
) -> None:
server = viser.ViserServer(share=share)
server.configure_theme(control_layout="collapsible", dark_mode=True)
server.configure_theme(control_layout="collapsible")
model = smplx.create(
model_path=str(model_path),
model_type=model_type,
Expand Down
Binary file not shown.
1 change: 1 addition & 0 deletions src/viser/client/public/viser_banner.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/viser/client/public/viser_banner_dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
94 changes: 77 additions & 17 deletions src/viser/client/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,15 @@ import {
import { BlendFunction, KernelSize } from "postprocessing";

import { SynchronizedCameraControls } from "./CameraControls";
import { Box, Image, MantineProvider, MediaQuery } from "@mantine/core";
import {
Anchor,
Box,
Image,
MantineProvider,
MediaQuery,
Modal,
useMantineTheme,
} from "@mantine/core";
import React from "react";
import { SceneNodeThreeObject, UseSceneTree } from "./SceneTree";

Expand All @@ -38,6 +46,7 @@ import { ViserModal } from "./Modal";
import { useSceneTreeState } from "./SceneTreeState";
import { GetRenderRequestMessage, Message } from "./WebsocketMessages";
import { makeThrottledMessageSender } from "./WebsocketFunctions";
import { useDisclosure } from "@mantine/hooks";

export type ViewerContextContents = {
// Zustand hooks.
Expand Down Expand Up @@ -124,6 +133,8 @@ function ViewerRoot() {
function ViewerContents() {
const viewer = React.useContext(ViewerContext)!;
const control_layout = viewer.useGui((state) => state.theme.control_layout);
const [aboutModelOpened, { open: openAbout, close: closeAbout }] =
useDisclosure(false);
return (
<MantineProvider
withGlobalStyles
Expand Down Expand Up @@ -163,22 +174,34 @@ function ViewerContents() {
<FrameSynchronizedMessageHandler />
</ViewerCanvas>
{viewer.useGui((state) => state.theme.show_logo) ? (
<Box
sx={{
position: "absolute",
bottom: "1em",
left: "1em",
filter: "saturate(0.625)",
"&:hover": {
filter: "saturate(1.0)",
},
}}
component="a"
target="_blank"
href="https://viser.studio"
>
<Image src="/logo.svg" width="2.5em" height="auto" />
</Box>
<>
<Box
sx={{
position: "absolute",
bottom: "1em",
left: "1em",
filter: "saturate(0.625)",
cursor: "pointer",
"&:hover": {
filter: "saturate(1.0)",
},
}}
component="a"
onClick={openAbout}
title="About Viser"
>
<Image src="/logo.svg" width="2.5em" height="auto" />
</Box>
<Modal
opened={aboutModelOpened}
onClose={closeAbout}
size="xl"
withCloseButton={false}
ta="center"
>
<AboutViser />
</Modal>
</>
) : null}
</Box>
</MediaQuery>
Expand Down Expand Up @@ -413,3 +436,40 @@ export function Root() {
</Box>
);
}

function AboutViser() {
return (
<Box>
<Image
src={
useMantineTheme().colorScheme === "dark"
? "viser_banner_dark.svg"
: "viser_banner.svg"
}
radius="xs"
/>
<Box mt="1.625em">
Viser is a 3D visualization toolkit developed at UC Berkeley.
</Box>
<p>
<Anchor
href="https://github.com/nerfstudio-project/viser"
target="_blank"
fw="800"
sx={{ "&:focus": { outline: "none" } }}
>
GitHub
</Anchor>
&nbsp;&nbsp;&bull;&nbsp;&nbsp;
<Anchor
href="https://viser.studio"
target="_blank"
fw="800"
sx={{ "&:focus": { outline: "none" } }}
>
Documentation
</Anchor>
</p>
</Box>
);
}
Loading

0 comments on commit 0a020fb

Please sign in to comment.