Skip to content

Commit

Permalink
Adding double side for mesh (#12)
Browse files Browse the repository at this point in the history
* trying to add mesh double side

* Sync message defs + built client

---------

Co-authored-by: Brent Yi <[email protected]>
  • Loading branch information
ethanweber and brentyi authored May 8, 2023
1 parent ca83635 commit eed8b09
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 8 deletions.
2 changes: 2 additions & 0 deletions viser/_message_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ def add_mesh(
| Tuple[float, float, float]
| onp.ndarray = (90, 200, 255),
wireframe: bool = False,
side: Literal["front", "back", "double"] = "front",
wxyz: Tuple[float, float, float, float] | onp.ndarray = (1.0, 0.0, 0.0, 0.0),
position: Tuple[float, float, float] | onp.ndarray = (0.0, 0.0, 0.0),
visible: bool = True,
Expand All @@ -520,6 +521,7 @@ def add_mesh(
# (255, 255, 255) => 0xffffff, etc
color=_encode_rgb(color),
wireframe=wireframe,
side=side
)
)
return SceneNodeHandle._make(self, name, wxyz, position, visible)
Expand Down
1 change: 1 addition & 0 deletions viser/_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ class MeshMessage(Message):
faces: onpt.NDArray[onp.uint32]
color: int
wireframe: bool
side: Literal["front", "back", "double"] = "front"

def __post_init__(self):
# Check shapes.
Expand Down
6 changes: 3 additions & 3 deletions viser/client/build/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"files": {
"main.css": "/static/css/main.82973013.css",
"main.js": "/static/js/main.6587bad7.js",
"main.js": "/static/js/main.3b78e278.js",
"index.html": "/index.html",
"main.82973013.css.map": "/static/css/main.82973013.css.map",
"main.6587bad7.js.map": "/static/js/main.6587bad7.js.map"
"main.3b78e278.js.map": "/static/js/main.3b78e278.js.map"
},
"entrypoints": [
"static/css/main.82973013.css",
"static/js/main.6587bad7.js"
"static/js/main.3b78e278.js"
]
}
2 changes: 1 addition & 1 deletion viser/client/build/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.svg"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>Viser</title><script defer="defer" src="/static/js/main.6587bad7.js"></script><link href="/static/css/main.82973013.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.svg"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/logo192.png"/><link rel="manifest" href="/manifest.json"/><title>Viser</title><script defer="defer" src="/static/js/main.3b78e278.js"></script><link href="/static/css/main.82973013.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>

Large diffs are not rendered by default.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions viser/client/src/WebsocketInterface.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ function useMessageHandler() {
const material = new THREE.MeshStandardMaterial({
color: message.color,
wireframe: message.wireframe,
side: {"front": THREE.FrontSide, "back": THREE.BackSide, "double": THREE.DoubleSide}[message.side],
});
geometry.setAttribute(
"position",
Expand Down
1 change: 1 addition & 0 deletions viser/client/src/WebsocketMessages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ interface MeshMessage {
faces: ArrayBuffer;
color: number;
wireframe: boolean;
side: "front" | "back" | "double";
}
interface TransformControlsMessage {
type: "TransformControlsMessage";
Expand Down

0 comments on commit eed8b09

Please sign in to comment.