Skip to content

Commit 3c9838d

Browse files
committed
feat(): Adding other model
1 parent 99f23ee commit 3c9838d

6 files changed

Lines changed: 80 additions & 20 deletions

File tree

public/IonDrive.glb

4.83 MB
Binary file not shown.

src/index.css

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
11
@tailwind base;
22
@tailwind components;
33
@tailwind utilities;
4+
5+
/* width */
6+
::-webkit-scrollbar {
7+
width: 8px;
8+
height: 6px;
9+
}
10+
11+
/* Track */
12+
::-webkit-scrollbar-track {
13+
box-shadow: inset 0 0 1px rgb(255, 255, 255);
14+
border-radius: 5px;
15+
}
16+
17+
::-webkit-scrollbar-track:horizontal {
18+
box-shadow: inset 0 0 1px rgb(255, 255, 255);
19+
border-radius: 5px;
20+
}
21+
/* Handle */
22+
::-webkit-scrollbar-thumb {
23+
background: violet;
24+
border-radius: 10px;
25+
box-shadow: 0 0 10px rgb(0, 0, 0);
26+
}

src/screens/mainFlow/scene/AdamHead.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const Model = forwardRef((props, ref) => {
1717
child.castShadow = true;
1818
child.receiveShadow = true;
1919
child.material.metalness = 0.7;
20-
child.material.roughness = 0.2;
20+
child.material.roughness = 0.5;
2121
child.material.envMapIntensity = 1;
2222
}
2323
});
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/* eslint-disable react/no-unknown-property */
2+
/*
3+
Auto-generated by: https://github.com/pmndrs/gltfjsx
4+
ExporterVersion: 2.2.0
5+
*/
6+
7+
import { useAnimations, useGLTF, useScroll } from '@react-three/drei';
8+
import { useFrame } from '@react-three/fiber';
9+
import { useEffect, useRef } from 'react';
10+
11+
useGLTF.preload('IonDrive.glb');
12+
13+
const Model = (props) => {
14+
const ref = useRef();
15+
const { scene, animations } = useGLTF('IonDrive.glb');
16+
const { actions } = useAnimations(animations, scene);
17+
18+
useEffect(() => {
19+
actions['Main'].play();
20+
}, [actions]);
21+
22+
// changing color of the model and adding glow effect
23+
scene.traverse((child) => {
24+
if (child.isMesh) {
25+
child.material.emissive.set('#8F00FF');
26+
child.material.emissiveIntensity = 0.2;
27+
}
28+
});
29+
return (
30+
<group ref={ref} position={[3, 0.5, -2]} scale={0.5}>
31+
<primitive object={scene} {...props} />
32+
</group>
33+
);
34+
};
35+
36+
export default Model;

src/screens/mainFlow/scene/LieutenantHead.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ const Model = forwardRef((props, ref) => {
2222
}
2323
});
2424
return (
25-
<group ref={ref} position={[0, 0, -1]}>
25+
<group ref={ref} position={[0, -0.4, -1]}>
2626
<primitive object={scene} {...props} />
2727
</group>
2828
);

src/screens/mainFlow/scene/RobotScene.tsx

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
/* eslint-disable react/no-unknown-property */
2-
import { Canvas, ThreeElements } from '@react-three/fiber';
2+
import { Canvas } from '@react-three/fiber';
33
import { lazy, Suspense, useEffect, useRef } from 'react';
44

55
import {
66
Environment,
77
Html,
8+
OrbitControls,
89
ScrollControls,
910
useProgress,
10-
useScroll,
1111
} from '@react-three/drei';
1212
import { Box, Progress } from '@chakra-ui/react';
13-
import { useMousePositions, useSpringMousePosition } from '@hooks';
13+
import { useMousePositions } from '@hooks';
1414
import gsap from 'gsap';
15-
import { useAnimate } from 'framer-motion';
16-
import { has } from 'lodash';
17-
import { Mesh } from 'three';
15+
import { DirectionalLight, Mesh } from 'three';
1816

1917
const LoaderComponent = () => {
2018
const { progress } = useProgress();
@@ -29,6 +27,7 @@ const LoaderComponent = () => {
2927

3028
const AdamHead = lazy(() => import('./AdamHead'));
3129
const LieutenantHead = lazy(() => import('./LieutenantHead'));
30+
const IonDrive = lazy(() => import('./IonDrive'));
3231

3332
const RobotScene = ({
3433
type = 'lieutenant',
@@ -47,8 +46,8 @@ const RobotScene = ({
4746
});
4847
if (!ref.current) return;
4948
tl.current.to(ref.current.rotation, {
50-
y: x !== 0 ? x / 2500 - 0.25 : -0.25,
51-
x: y !== 0 ? -y / 2500 - 0.2 : -0.2,
49+
y: x !== 0 ? x / 5000 - 0.18 : -0.25,
50+
x: y !== 0 ? -y / 5000 - 0.17 : -0.2,
5251
duration: 1.5,
5352
});
5453

@@ -68,22 +67,24 @@ const RobotScene = ({
6867
dpr={[1, 2]}
6968
performance={{ min: 0.1, max: 1 }}
7069
camera={{
71-
position: [0, -5, -20],
72-
fov: 10,
70+
position: [0, -3, -20],
71+
fov: 12,
7372
}}
7473
>
7574
<ambientLight intensity={0.5} color={'violet'} />
7675
<spotLight position={[10, 10, 10]} angle={0.15} penumbra={1} />
76+
<directionalLight position={[0, 0, 1]} intensity={0.5} />
7777
<Suspense fallback={<LoaderComponent />}>
78-
<ScrollControls pages={3} damping={10}>
79-
{type === 'adam' ? (
80-
<AdamHead ref={ref} />
81-
) : (
82-
<LieutenantHead ref={ref} />
83-
)}
84-
</ScrollControls>
78+
{type === 'adam' ? (
79+
<AdamHead ref={ref} />
80+
) : (
81+
<LieutenantHead ref={ref} />
82+
)}
8583
</Suspense>
86-
<Environment preset="dawn" blur={0.2} />
84+
<Suspense>
85+
<IonDrive />
86+
</Suspense>
87+
<Environment preset="city" blur={0.8} />
8788
</Canvas>
8889
);
8990
};

0 commit comments

Comments
 (0)