Skip to content

Commit d081260

Browse files
committed
test spinning change
1 parent 5a23f18 commit d081260

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/pages/Home.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { getRecentEvents2Info } from "../components/recentEvents2Info.js";
66
import { getRecentEvents3Info } from "../components/recentEvents3Info.js";
77
import { getRecentEvents4Info } from "../components/recentEvents4Info.js";
88

9-
import { OrbitControls, useTexture } from "@react-three/drei";
10-
import { Canvas, useLoader } from "@react-three/fiber";
9+
import { useTexture } from "@react-three/drei";
10+
import { Canvas, useFrame, useLoader } from "@react-three/fiber";
1111
import { Mesh, NoToneMapping } from "three";
1212
import { MTLLoader } from "three/examples/jsm/loaders/MTLLoader.js";
1313
import { OBJLoader } from "three/examples/jsm/loaders/OBJLoader";
@@ -19,6 +19,7 @@ import "react-multi-carousel/lib/styles.css";
1919
import "./Home.css";
2020

2121
const Truck = () => {
22+
const groupRef = useRef();
2223
const texture = useTexture("firetruck/FireEngine.png");
2324
const materials = useLoader(MTLLoader, "firetruck/FireEngine.mtl");
2425
const obj = useLoader(OBJLoader, "firetruck/FireEngine.obj", (loader) => {
@@ -31,10 +32,17 @@ const Truck = () => {
3132
child.material.map = texture;
3233
}
3334
});
35+
36+
useFrame(() => {
37+
if (groupRef.current) {
38+
groupRef.current.rotation.y += 0.01;
39+
}
40+
});
41+
3442
const position = [0.5, -0.6, 0.3];
3543
const rotation = [0.4, -0.8, 0];
3644
return (
37-
<group position={position} rotation={rotation}>
45+
<group ref={groupRef} position={position} rotation={rotation}>
3846
<primitive object={obj} scale={0.65} />
3947
</group>
4048
);
@@ -310,7 +318,6 @@ export default function Home() {
310318
<pointLight position={[5, 3, 5]} intensity={20} />
311319
<Suspense fallback={null}>
312320
<Truck className="truck" />
313-
<OrbitControls />
314321
</Suspense>
315322
</Canvas>
316323
</div>

0 commit comments

Comments
 (0)