Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add clonepbject3 #47

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
Binary file added public/catbeta1.glb
Binary file not shown.
Binary file added public/catbeta2.glb
Binary file not shown.
57 changes: 51 additions & 6 deletions src/components/Cat.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,60 @@
import { useAnimations, useGLTF } from "@react-three/drei";
import { Clone, useAnimations, useGLTF } from "@react-three/drei";
import { useFrame } from "@react-three/fiber";
import { useRef } from "react";

const Cat = () => {
const { scene, animations } = useGLTF("cat.glb");
const CloneCat = ({
scene,
animations,
position,
animationName,
}: {
scene: any;
animations: any;
position: any;
animationName: str;
}) => {
const ref = useRef();
const { actions } = useAnimations(animations, ref);
console.log(scene);
useFrame(() => {
actions.walk?.play();
actions[animationName]?.play();
});
return <primitive object={scene} ref={ref} />;
return (
<Clone
object={scene}
scale={0.35}
position-x={-8}
ref={ref}
position={position}
/>
);
};

const Cat = () => {
const { scene, animations } = useGLTF("/catbeta2.glb");
// const ref = useRef();
// const { actions } = useAnimations(animations, ref);
// console.log(scene);
// useFrame(() => {
// actions.stay?.play();
// });
return (
<>
{/* <primitive object={scene} ref={ref} scale={0.35} />
<Clone object={scene} scale={0.35} position-x={-4} ref={ref} />
<Clone object={scene} scale={0.35} position-x={-8} ref={ref} /> */}
<CloneCat
scene={scene}
animations={animations}
position={[0, 0, 0]}
animationName="stay"
/>
<CloneCat
scene={scene}
animations={animations}
position={[5, 0, 50]}
animationName="sit"
/>
</>
);
};
export default Cat;
6 changes: 3 additions & 3 deletions src/components/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ export const Header = () => {
sx={{
backgroundColor: "#fffff0",
width: "100%",
height: "13vh",
height: "6vh",
margin: "0 0",
}}
>
<Image
src="/images/nyan.gif"
alt="nyan.gif"
height={100}
width={100}
height={45}
width={45}
/>
</Box>
);
Expand Down
9 changes: 7 additions & 2 deletions src/components/Request.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import DatePick from "../components/DatePick";

export default function Request() {
const [isOpen, setIsOpen] = useState(false);
const [isClose, setIsClose] = useState(false);
return (
<div>
<Button
Expand Down Expand Up @@ -55,12 +56,16 @@ export default function Request() {
<Image
src="/images/catclose.png"
alt="cat close.png"
width={100}
height={100}
style={{
textAlign: "right",
position: "absolute",
right: 0,
width: "15%",
height: "20%",
top: 0,
}}
onClick={() => {
setIsClose(isClose);
}}
/>

Expand Down
14 changes: 11 additions & 3 deletions src/pages/todo.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import { TodoAdd } from "@/components/Todoadd";
import Cat from "@/components/Cat";
import { ScheduleCalendar } from "@/components/schedule/ScheduleCalender";
import { TodoAdd } from "@/components/Todoadd";
import { Box, Stack } from "@mui/material";
// import DataPicker from "../components/DataPicker";
import { OrbitControls } from "@react-three/drei";
import { Canvas } from "@react-three/fiber";
export default function Todo() {
return (
<Stack direction="row">
<Box component="div" sx={{ height: "100vh", width: "60%" }}></Box>
<Box component="div" sx={{ height: "100vh", width: "60%" }}>
<Canvas>
<OrbitControls />
<Cat />
<directionalLight />
</Canvas>
</Box>
<Box
component="div"
sx={{ height: "100vh", width: "40%" }}
Expand Down