Skip to content

Commit 76b4041

Browse files
committed
GEP-200 make changes
1 parent 053d3d4 commit 76b4041

File tree

9 files changed

+83
-12
lines changed

9 files changed

+83
-12
lines changed

examples/vite-3DCanvas-react-app/src/components/toolbar/groups/Backward3D.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react";
2-
import { Toolbar3DButton } from "../Toolbar3D";
2+
import { Toolbar3DButton } from "../toolbar";
33

44
const Backward3D: React.FC = () => {
55
return (

examples/vite-3DCanvas-react-app/src/components/toolbar/groups/Forward3D.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react";
2-
import { Toolbar3DButton } from "../Toolbar3D";
2+
import { Toolbar3DButton } from "../toolbar";
33

44
const Forward3D: React.FC = () => {
55
return (

examples/vite-3DCanvas-react-app/src/components/toolbar/groups/PanLeft3D.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react";
2-
import { Toolbar3DButton } from "../Toolbar3D";
2+
import { Toolbar3DButton } from "../toolbar";
33

44
const PanLeft3D: React.FC = () => {
55
return (

examples/vite-3DCanvas-react-app/src/components/toolbar/groups/PanRight3D.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react";
2-
import { Toolbar3DButton } from "../Toolbar3D";
2+
import { Toolbar3DButton } from "../toolbar";
33

44
const PanRight3D: React.FC = () => {
55
return (

examples/vite-3DCanvas-react-app/src/components/toolbar/groups/RotationGroup3D.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react";
2-
import { Toolbar3DButton } from "../Toolbar3D";
2+
import { Toolbar3DButton } from "../toolbar";
33

44
const Animation3DControls: React.FC = () => {
55
return (

examples/vite-3DCanvas-react-app/src/components/toolbar/groups/ZoomGroup3D.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react";
2-
import { Toolbar3DButton } from "../Toolbar3D";
2+
import { Toolbar3DButton } from "../toolbar";
33

44
const Zoom3DButtons: React.FC = () => {
55
return (
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import Toolbar3D, { Toolbar3DButton, Toolbar3DSeparator } from './toolbar';
2+
3+
export { Toolbar3D, Toolbar3DButton, Toolbar3DSeparator };
4+
export default Toolbar3D;
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import React from 'react';
2+
import { Box, SxProps, Theme, Divider } from '@mui/material';
3+
4+
const baseStyles: SxProps<Theme> = {
5+
display: "flex",
6+
flexDirection: "column",
7+
alignItems: "center",
8+
backgroundColor: "#f0f0f0"
9+
}
10+
11+
12+
const baseButtonStyles: React.CSSProperties = {
13+
padding: "0.75rem",
14+
fontSize: "1.25rem",
15+
color: "#666",
16+
display: "flex",
17+
alignItems: "center",
18+
justifyContent: "center",
19+
cursor: "pointer"
20+
}
21+
22+
const Toolbar3D = ({ children, sx, canvasId }: {
23+
children: React.ReactNode,
24+
sx?: SxProps<Theme>,
25+
canvasId?: string
26+
}) => {
27+
return (
28+
<Box sx={{ ...baseStyles, ...sx }} data-canvas-id={canvasId}>
29+
{children}
30+
</Box>
31+
);
32+
}
33+
34+
35+
const Toolbar3DButton = ({ icon, tooltip, onClick, style }: {
36+
icon: React.ReactNode,
37+
tooltip: string,
38+
onClick: (context: { camera?: any, [key: string]: any }) => void,
39+
style?: React.CSSProperties
40+
}) => {
41+
const handleClick = () => {
42+
// Here we can gather context data that might be useful
43+
// For now, let's provide a basic camera context
44+
const context = {
45+
camera: "default-camera", // This could be retrieved from React context, props, or refs
46+
// You can add more context data here as needed
47+
};
48+
onClick(context);
49+
};
50+
51+
return (
52+
<button style={{ ...baseButtonStyles, ...style }} title={tooltip} onClick={handleClick}>
53+
{icon}
54+
</button>
55+
);
56+
}
57+
58+
const Toolbar3DSeparator = () => {
59+
return (
60+
<Divider
61+
orientation="horizontal"
62+
sx={{
63+
width: '100%',
64+
my: 0.5
65+
}}
66+
/>
67+
)
68+
}
69+
70+
export { Toolbar3D, Toolbar3DButton, Toolbar3DSeparator };
71+
export default Toolbar3D;

examples/vite-3DCanvas-react-app/src/components/viewers/Canvas3DExample.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ import { Canvas3D } from "@metacell/geppetto-meta-ui/3d-canvas/Canvas3D";
33
import { Box } from "@mui/material";
44
import { useFrame } from "@react-three/fiber";
55
import { Mesh } from "three";
6-
import {
7-
Toolbar3DButton,
8-
Toolbar3D,
9-
Toolbar3DSeparator,
10-
} from "../toolbar/Toolbar3D";
6+
import { Toolbar3DButton, Toolbar3D, Toolbar3DSeparator } from "../toolbar";
117
import {
128
Navigation3D,
139
Zoom3DButtons,
@@ -86,7 +82,7 @@ const Canvas3DExample: React.FC = () => {
8682
<Toolbar3DButton
8783
icon={<i className="fas fa-camera" />}
8884
tooltip="Camera"
89-
onClick={({ camera }) => console.log("Camera clicked", camera)}
85+
onClick={() => console.log("Camera clicked")}
9086
/>
9187
</Toolbar3D>
9288
<Box sx={classes.canvasContainer}>

0 commit comments

Comments
 (0)