Skip to content

Commit

Permalink
added clipboard for paddle
Browse files Browse the repository at this point in the history
  • Loading branch information
Rice-Tech committed Jan 29, 2024
1 parent 16499ed commit 3ea7ca7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/components/Ball.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function Ball(props: Props) {
return;
}
const ball = rigidBodyRef.current;
if (ball.translation().y < -3) {
if (ball.translation().y < -4.6) {
rigidBodyRef.current.setTranslation({ x: 0, y: 5, z: 0 }, true);
rigidBodyRef.current.setLinvel({ x: 0, y: 5, z: 0 }, true);
state.api.reset();
Expand Down
13 changes: 5 additions & 8 deletions src/components/Clipboard.tsx → src/components/Clipboard2.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
/*
Auto-generated by: https://github.com/pmndrs/gltfjsx
Command: npx gltfjsx@6.2.16 src/resources/Props_3D/Clipboard.glb -t
*/

import * as THREE from "three";
import { useGLTF } from "@react-three/drei";
import { GLTF } from "three-stdlib";
Expand All @@ -16,16 +11,18 @@ type GLTFResult = GLTF & {
};
};

export function ClipboardModel(props: JSX.IntrinsicElements["group"]) {
export function Clipboard2(props: JSX.IntrinsicElements["group"]) {
const { nodes, materials } = useGLTF("/Clipboard.glb") as GLTFResult;
return (
<group {...props} dispose={null}>
<group {...props} dispose={null} scale={[25,25,25]}>
<mesh
castShadow
receiveShadow
geometry={nodes.Clipboard.geometry}
material={materials.Clipboard}
/>
</group>
);
}

useGLTF.preload("../resources/Props_3D/Clipboard.glb");
useGLTF.preload("/Clipboard.glb");
13 changes: 6 additions & 7 deletions src/components/Paddle.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Text } from "@react-three/drei";
import { useFrame } from "@react-three/fiber";
import {
ContactForcePayload,
CylinderCollider,
CuboidCollider,
RapierRigidBody,
RigidBody,
} from "@react-three/rapier";
Expand All @@ -11,9 +11,8 @@ import { useCallback, useRef } from "react";
import * as THREE from "three";
import { useSnapshot } from "valtio";
import { state } from "@/MiniGame1";
import { PingPong } from "./Pingpong";
import { useGatherWords } from "../contexts/GatherWordsContext";
//import { ClipboardModel } from "./Clipboard";
import { Clipboard2 } from "./Clipboard2";

export function Paddle({
vec = new THREE.Vector3(),
Expand Down Expand Up @@ -65,23 +64,23 @@ export function Paddle({
colliders={false}
onContactForce={contactForce}
>
<CylinderCollider args={[0.15, 1.75]} />
<CuboidCollider args={[2.3,0.5,3]} position={[0,-0.3,0]} />
<group ref={model} position={[0, 2, 0]} scale={0.15}>
<Text
anchorX="center"
anchorY="middle"
rotation={[-Math.PI / 2, 0, 0]}
position={[-3, 1, 0]}
position={[-1, 1, 0]}
fontSize={5}
color={"black"}
>
{count + "\n"}
{contextWords
.map((word, index) => `${index + 1}) ${word.word}`)
.join("\n")}
</Text>
<group rotation={[0, -0.04, 0]} scale={1}>
<PingPong></PingPong>
{/* <ClipboardModel /> */}
<Clipboard2 position={[0,0,0]}/>
</group>
</group>
</RigidBody>
Expand Down

0 comments on commit 3ea7ca7

Please sign in to comment.