1- import { useThree , extend , useFrame } from '@react-three/fiber '
1+ import { MeshReflectorMaterial , Float , Text , Html , PivotControls , TransformControls , OrbitControls } from '@react-three/drei '
22import { useRef } from 'react'
3- import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js'
4- import CustomObject from './CustomObject.jsx'
5-
6- extend ( { OrbitControls } )
73
84export default function Experience ( )
95{
10- const { camera, gl } = useThree ( )
11-
12- const cubeRef = useRef ( )
13- const groupRef = useRef ( )
14-
15- useFrame ( ( state , delta ) =>
16- {
17- // const angle = state.clock.elapsedTime
18- // state.camera.position.x = Math.sin(angle) * 8
19- // state.camera.position.z = Math.cos(angle) * 8
20- // state.camera.lookAt(0, 0, 0)
21-
22- cubeRef . current . rotation . y += delta
23- // groupRef.current.rotation.y += delta
24- } )
6+ const cube = useRef ( )
7+ const sphere = useRef ( )
258
269 return < >
27- < orbitControls args = { [ camera , gl . domElement ] } />
10+
11+ < OrbitControls makeDefault />
2812
2913 < directionalLight position = { [ 1 , 2 , 3 ] } intensity = { 4.5 } />
3014 < ambientLight intensity = { 1.5 } />
3115
32- < group ref = { groupRef } >
33- < mesh position-x = { - 2 } >
16+ < PivotControls
17+ anchor = { [ 0 , 0 , 0 ] }
18+ depthTest = { false }
19+ lineWidth = { 4 }
20+ axisColors = { [ '#9381ff' , '#ff4d6d' , '#7ae582' ] }
21+ scale = { 200 }
22+ fixed = { true }
23+ >
24+ < mesh ref = { sphere } position-x = { - 2 } >
3425 < sphereGeometry />
3526 < meshStandardMaterial color = "orange" />
27+ { /* <Html
28+ position={ [ 1, 1, 0 ] }
29+ wrapperClass="label"
30+ center
31+ distanceFactor={ 8 }
32+ occlude={ [ sphere, cube ] }
33+ >
34+ That's a sphere 👍
35+ </Html> */ }
3636 </ mesh >
37+ </ PivotControls >
3738
38- < mesh ref = { cubeRef } rotation-y = { Math . PI * 0.25 } position-x = { 2 } scale = { 1.5 } >
39- < boxGeometry />
40- < meshStandardMaterial color = "mediumpurple" />
41- </ mesh >
42- </ group >
39+ < mesh ref = { cube } position-x = { 2 } scale = { 1.5 } >
40+ < boxGeometry />
41+ < meshStandardMaterial color = "mediumpurple" />
42+ </ mesh >
43+
44+ < TransformControls object = { cube } />
4345
4446 < mesh position-y = { - 1 } rotation-x = { - Math . PI * 0.5 } scale = { 10 } >
4547 < planeGeometry />
46- < meshStandardMaterial color = "greenyellow" />
48+ < MeshReflectorMaterial
49+ resolution = { 512 }
50+ blur = { [ 1000 , 1000 ] }
51+ mixBlur = { 1 }
52+ mirror = { 0.5 }
53+ color = "greenyellow"
54+ />
4755 </ mesh >
4856
49- < CustomObject />
57+ < Float
58+ speed = { 5 }
59+ floatIntensity = { 2 }
60+ >
61+ < Text
62+ font = "./bangers-v20-latin-regular.woff"
63+ fontSize = { 1 }
64+ color = "salmon"
65+ position-y = { 2 }
66+ maxWidth = { 2 }
67+ textAlign = "center"
68+ >
69+ I LOVE R3F
70+ </ Text >
71+ </ Float >
72+
5073 </ >
5174}
0 commit comments