{"id":13439,"date":"2023-02-02T14:30:57","date_gmt":"2023-02-02T05:30:57","guid":{"rendered":"http:\/\/www.gisdeveloper.co.kr\/?p=13439"},"modified":"2023-02-05T10:00:47","modified_gmt":"2023-02-05T01:00:47","slug":"r3f-%ec%bd%94%eb%93%9c-%ec%a0%95%eb%a6%ac","status":"publish","type":"post","link":"http:\/\/www.gisdeveloper.co.kr\/?p=13439","title":{"rendered":"R3F \ucf54\ub4dc \uc815\ub9ac"},"content":{"rendered":"<p>R3F\ub294 \ub2e4\uc74c\ucc98\ub7fc \uc124\uce58\ub420 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<p><code>npm install three@0.148 @react-three\/fiber@8.9<\/code><\/p>\n<p>\ub610\ub294 <\/p>\n<p><code>npm install three @react-three\/fiber<\/code><\/p>\n<p>\uc2dc\uc791\uc810\uc774 \ub418\ub294 index.jsx \ucf54\ub4dc \uc608\ub294 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"jsx\">\r\nimport { Canvas } from \"@react-three\/fiber\"\r\nimport MyThree from '.\/MyThree'\r\n\r\nconst root = createRoot(document.querySelector('#root'))\r\n\r\nroot.render(\r\n    <Canvas>\r\n        <MyThree><\/MyThree>\r\n    <\/Canvas>\r\n)\r\n<\/pre>\n<p>MyThree\ub294 \ucef4\ud3ec\ub10c\ud2b8\uc778\ub370, \ucf54\ub4dc\ub294 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"jsx\">\r\nimport { extend, useFrame, useThree } from \"@react-three\/fiber\"\r\nimport { useRef } from \"react\"\r\nimport { OrbitControls } from \"three\/examples\/jsm\/controls\/OrbitControls\"\r\n\r\nextend({ OrbitControls })\r\n\r\nexport default function MyThree() {\r\n    const cubeRef = useRef()\r\n\r\n    useFrame((state, delta) => {\r\n        cubeRef.current.rotation.y += delta\r\n    })\r\n\r\n    const { camera, gl } = useThree()\r\n\r\n    return <>\r\n        <ambientLight intensity={0.25}><\/ambientLight>\r\n        <directionalLight position={[1,2,3]} intensity={1.5}><\/directionalLight>\r\n\r\n        <mesh ref={cubeRef} scale={2}>\r\n            <boxGeometry><\/boxGeometry>\r\n            <meshNormalMaterial><\/meshNormalMaterial>\r\n        <\/mesh>\r\n\r\n        <orbitControls args={[camera, gl.domElement ]}><\/orbitControls>\r\n    &lt;\/>\r\n}\r\n<\/pre>\n<p>\ud050\ube0c \ud68c\uc804\uc5d0 \ub300\ud55c \uc560\ub2c8\uba54\uc774\uc158 \ucc98\ub9ac\uc640 OrbitControls\uac00 \uc801\uc6a9\ub41c \ucf54\ub4dc\uc785\ub2c8\ub2e4. \ubb3c\ub860 drei\ub97c \uc0ac\uc6a9\ud558\uba74 \ub354\uc6b1 \uac04\ub2e8\ud788 OrbitControls\ub97c \uc801\uc6a9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>R3F\ub294 \ub2e4\uc74c\ucc98\ub7fc \uc124\uce58\ub420 \uc218 \uc788\uc2b5\ub2c8\ub2e4. npm install three@0.148 @react-three\/fiber@8.9 \ub610\ub294 npm install three @react-three\/fiber \uc2dc\uc791\uc810\uc774 \ub418\ub294 index.jsx \ucf54\ub4dc \uc608\ub294 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4. import { Canvas } from &#8220;@react-three\/fiber&#8221; import MyThree from &#8216;.\/MyThree&#8217; const root = createRoot(document.querySelector(&#8216;#root&#8217;)) root.render( ) MyThree\ub294 \ucef4\ud3ec\ub10c\ud2b8\uc778\ub370, \ucf54\ub4dc\ub294 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4. import { extend, useFrame, useThree } from &#8220;@react-three\/fiber&#8221; import { useRef } from &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.gisdeveloper.co.kr\/?p=13439\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;R3F \ucf54\ub4dc \uc815\ub9ac&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-13439","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/13439","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=13439"}],"version-history":[{"count":10,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/13439\/revisions"}],"predecessor-version":[{"id":13452,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/13439\/revisions\/13452"}],"wp:attachment":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=13439"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=13439"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=13439"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}