From a1f73883c0df824d6370b9ae05ba60a62ccc34d1 Mon Sep 17 00:00:00 2001 From: chaadiic Date: Thu, 9 Jan 2025 02:50:40 +0100 Subject: [PATCH] disable rotation with prop /claim #103 --- src/CadViewer.tsx | 11 ++++------- src/CadViewerContainer.tsx | 5 +++-- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/CadViewer.tsx b/src/CadViewer.tsx index 28fc69e..c53dedd 100644 --- a/src/CadViewer.tsx +++ b/src/CadViewer.tsx @@ -21,12 +21,13 @@ import { Error3d } from "./three-components/Error3d" interface Props { soup?: AnySoupElement[] + autoRotateDisabled?: boolean } export const CadViewer = forwardRef< THREE.Object3D, React.PropsWithChildren ->(({ soup, children }, ref) => { +>(({ soup, children, autoRotateDisabled }, ref) => { const [hoveredComponent, setHoveredComponent] = useState + {boardStls.map(({ stlUrl, color }, index) => ( { - // TODO this should be done by onUnhover if (!e) { setHoveredComponent(null) } @@ -81,10 +81,7 @@ export const CadViewer = forwardRef< }) }} cad_component={cad_component} - isHovered={ - hoveredComponent?.cad_component_id === - cad_component.cad_component_id - } + isHovered={hoveredComponent?.cad_component_id === cad_component.cad_component_id} /> ))} diff --git a/src/CadViewerContainer.tsx b/src/CadViewerContainer.tsx index a19e045..6529eea 100644 --- a/src/CadViewerContainer.tsx +++ b/src/CadViewerContainer.tsx @@ -22,12 +22,13 @@ interface Props { name: string mousePosition: [number, number, number] } | null + autoRotateDisabled?: boolean } export const CadViewerContainer = forwardRef< THREE.Object3D, React.PropsWithChildren ->(({ children, hoveredComponent }, ref) => { +>(({ children, hoveredComponent, autoRotateDisabled }, ref) => { return (
- + {!autoRotateDisabled && }