Skip to content

Commit

Permalink
Fix: button group event triggers, camera frustum scale + click bugs (#…
Browse files Browse the repository at this point in the history
…332)

* Fix minor bugs: button group event triggers, camera frustum scale

* Fix camera frustums without click callbacks
  • Loading branch information
brentyi authored Nov 12, 2024
1 parent e473b33 commit 360a66c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/viser/_gui_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,8 @@ def add_button_group(
visible=visible,
),
),
)
is_button=True,
),
)

def add_checkbox(
Expand Down
17 changes: 10 additions & 7 deletions src/viser/client/src/ThreeAssets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -722,15 +722,18 @@ export const CameraFrustum = React.forwardRef<
let z = 1.0;

const volumeScale = Math.cbrt((x * y * z) / 3.0);
x /= volumeScale * props.scale;
y /= volumeScale * props.scale;
z /= volumeScale * props.scale;
x /= volumeScale;
y /= volumeScale;
z /= volumeScale;
x *= props.scale;
y *= props.scale;
z *= props.scale;

const hoveredRef = React.useContext(HoverableContext)!;
const hoveredRef = React.useContext(HoverableContext);
const [isHovered, setIsHovered] = React.useState(false);

useFrame(() => {
if (hoveredRef.current !== isHovered) {
if (hoveredRef !== null && hoveredRef.current !== isHovered) {
setIsHovered(hoveredRef.current);
}
});
Expand Down Expand Up @@ -771,12 +774,12 @@ export const CameraFrustum = React.forwardRef<
/>
{imageTexture && (
<mesh
position={[0.0, 0.0, props.scale * z]}
position={[0.0, 0.0, z]}
rotation={new THREE.Euler(Math.PI, 0.0, 0.0)}
>
<planeGeometry
attach="geometry"
args={[props.scale * props.aspect * y * 2, props.scale * y * 2]}
args={[props.aspect * y * 2, y * 2]}
/>
<meshBasicMaterial
attach="material"
Expand Down

0 comments on commit 360a66c

Please sign in to comment.