250x250
Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 | 31 |
Tags
- jQuery
- 개발자
- javascript
- 비전공자
- 애니메이션
- 프론트엔드
- SWIFT
- php
- 비전공 개발자
- image
- iPhone
- iOS 개발자
- front-end
- HTML
- xcode
- CSS
- html5
- MAC
- IOS
- effect
- 백엔드
- css3
- 자바스크립트
- hover
- Animation
- ipad
- react
- button
- 풀스택
- keyframes
Archives
- Today
- Total
비전공자 개발일기
three.js 본문
728x90
SMALL


* npm i three @react-three/fiber *
box.js
import { useFrame } from "@react-three/fiber";
import { useState, useRef } from "react";
export default function Box({ color, ...props }) {
const [isHovered, setIsHovered] = useState(false);
const ref = useRef();
useFrame(() => {
ref.current.rotation.x += 0.01;
ref.current.rotation.y += 0.01;
});
return (
<mesh
ref={ref}
scale={isHovered ? 1.5 : 1}
onPointerOver={() => {
setIsHovered(true);
}}
onPointerOut={() => {
setIsHovered(false);
}}
{...props}
>
<pointLight></pointLight>
<boxBufferGeometry></boxBufferGeometry>
<meshPhysicalMaterial color={color}></meshPhysicalMaterial>
</mesh>
);
}
App.js
import { Canvas } from "@react-three/fiber";
import Box from "./component/box";
export default function App() {
return (
<div style={{ width: "100vw", height: "100vh" }}>
<Canvas style={{ backgroundColor: "#000" }}>
<ambientLight intensity={0.3}>
<Box color="green" position={[3, 0, 0]}></Box>
<Box color="red" position={[-3, 0, 0]}></Box>
<Box color="yellow" position={[0, 0, 0]}></Box>
</ambientLight>
</Canvas>
</div>
);
}728x90
LIST
'React & React Native' 카테고리의 다른 글
| React & Vue & Svelte (0) | 2023.05.01 |
|---|---|
| React Native Flipper-Glog Error (0) | 2022.05.23 |
| React Native Login & Basic Page (0) | 2022.02.27 |
| React Native Webview2 (0) | 2022.02.14 |
| React Native Webview (0) | 2022.02.13 |