{"id":13951,"date":"2023-07-28T18:00:39","date_gmt":"2023-07-28T09:00:39","guid":{"rendered":"http:\/\/www.gisdeveloper.co.kr\/?p=13951"},"modified":"2023-07-30T12:40:26","modified_gmt":"2023-07-30T03:40:26","slug":"useref%eb%a1%9c-%ec%9a%94%ec%86%8c%ea%b0%80-%ec%b0%b8%ec%a1%b0%eb%90%a0-%eb%95%8c-%eb%8b%a4%ec%8b%9c-%ec%bb%b4%ed%8f%ac%eb%84%8c%ed%8a%b8-%eb%a0%8c%eb%8d%94%eb%a7%81%ed%95%98%ea%b8%b0","status":"publish","type":"post","link":"http:\/\/www.gisdeveloper.co.kr\/?p=13951","title":{"rendered":"useRef\ub85c \uc694\uc18c\uac00 \ucc38\uc870\ub420 \ub54c \ub2e4\uc2dc \ucef4\ud3ec\ub10c\ud2b8 \ub80c\ub354\ub9c1\ud558\uae30"},"content":{"rendered":"<p>React\ub294 \uc120\uc5b8\ud615 \ud504\ub85c\uadf8\ub798\ubc0d\uc744 \uc9c0\ud5a5\ud569\ub2c8\ub2e4. \uc5b4\ub5a4 \uc2dc\uac01\uc801\uc778 \uc694\uc18c\ub97c \uc790\uc2dd\uc73c\ub85c \uc120\uc5b8\ud574\uc11c \uc6f9\ube0c\ub77c\uc6b0\uc800\uc5d0 \ud45c\uc2dc\ud558\ub294\ub370\uc694. \uc5b4\ub5a4 \uc694\uc18c\ub97c \ucc38\uc870\ud558\uae30 \uc704\ud574 useRef \ud6c5\uc744 \uc0ac\uc6a9\ud569\ub2c8\ub2e4. \uadf8\ub7f0\ub370 \ucc98\uc74c \ucef4\ud3ec\ub10c\ud2b8\uac00 \ub9c8\uc6b4\ud2b8 \ub420\ub54c useRef\ub85c \ucc38\uc870\ud558\uace0\uc790 \ud558\ub294 \uc694\uc18c\uac00 \uc544\uc9c1 \ucc38\uc870\ub418\uc9c0 \uc54a\uc744 \ub54c\uac00 \uc788\uc2b5\ub2c8\ub2e4. \uc774\ub7f4 \ub54c useRef\ub85c \uc5b4\ub5a4 \uc694\uc18c\uac00 \uc81c\ub300\ub85c \ucc38\uc870\ub420 \ub54c \ub2e4\uc2dc \ucef4\ud3ec\ub10c\ud2b8\ub97c \ub80c\ub354\ub9c1\ud574 \uc904 \ud544\uc694\uac00 \uc788\ub294\ub370\uc694.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"jsx\">\r\nimport { OrbitControls } from \"@react-three\/drei\"\r\nimport { useRef, useState } from \"react\";\r\nimport * as THREE from \"three\"\r\n\r\nfunction Outline(props) {\r\n  const material = useMemo(\r\n    () => new THREE.LineBasicMaterial({ color: 0xffff00 }),\r\n    []\r\n  ) \r\n\r\n  return &lt;lineSegments \r\n    geometry={props.geometry} \r\n    material={material}\r\n  \/>\r\n}\r\n\r\nfunction MyElement3D() {\r\n  const refMesh = useRef()\r\n  const [, setRefAllocated ] = useState(false)\r\n\r\n  return (\r\n    &lt;>\r\n      &lt;OrbitControls \/>\r\n\r\n      &lt;ambientLight intensity={0.1} \/>\r\n      &lt;directionalLight position={[2, 1, 3]} intensity={0.5} \/>\r\n\r\n      &lt;mesh \r\n        ref={self => { refMesh.current = self; setRefAllocated(true) }}\r\n        position={[-1.2, 0, 0]}>\r\n        &lt;boxGeometry args={[1,1,1,10,10,10]} \/>\r\n        &lt;meshStandardMaterial color=\"#8e44ad\" \/>\r\n        &lt;Outline geometry={refMesh.current?.geometry} \/>\r\n      &lt;\/mesh>\r\n    &lt;\/>\r\n  )\r\n}\r\n\r\nexport default MyElement3D\r\n<\/pre>\n<p>\uc0c1\uad00\uc5c6\ub294 \ucf54\ub4dc\uac00 90%\uace0 \uc774 \uae00\uacfc \uad00\ub828\ub41c \ucf54\ub4dc\uac00 10%\uc778\ub370\uc694. 14\ubc88\uc5d0 useRef\uc5d0 \ub300\ud55c refMesh\uac00 \uc788\uace0, refMesh\uac00 \ucc38\uc870\ud558\ub294 \uac83\uc774 25\ubc88 \ucf54\ub4dc\uc5d0 \ubcf4\uc785\ub2c8\ub2e4. \uadf8\ub7f0\ub370 ref\uc5d0 \ub300\ud55c \uc9c0\uc815\uc744 \ud568\uc218\ub85c \uc9c0\uc815\ud558\uace0 \uc788\ub2e4\ub294 \uc810\uc785\ub2c8\ub2e4. refMesh\uc5d0 \uc694\uc18c\uac00 \ucc38\uc870\ub418\uba74 15\ubc88 \ucf54\ub4dc\uc5d0\uc11c \ub9cc\ub4e4\uc5b4 \ub454 \uc0c1\ud0dc \ubcc0\uacbd \ud568\uc218\ub97c \ud638\ucd9c\ud558\ub294\ub370\uc694. React\uc5d0\uc11c \uc0c1\ud0dc \ubcc0\uacbd\uc740 \ucef4\ud3ec\ub10c\ud2b8 \ud568\uc218\uc758 \uc7ac\uc2e4\ud589\uc744 \uc758\ubbf8\ud558\ubbc0\ub85c refMesh\uc5d0 \uc5b4\ub5a4 \uc694\uc18c\uac00 \ud560\ub2f9\ub418\uba74 \ub2e4\uc2dc \ucef4\ud3ec\ub10c\ud2b8\ub97c \ub80c\ub354\ub9c1\ud558\ub3c4\ub85d \uc720\ub3c4\ud569\ub2c8\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>React\ub294 \uc120\uc5b8\ud615 \ud504\ub85c\uadf8\ub798\ubc0d\uc744 \uc9c0\ud5a5\ud569\ub2c8\ub2e4. \uc5b4\ub5a4 \uc2dc\uac01\uc801\uc778 \uc694\uc18c\ub97c \uc790\uc2dd\uc73c\ub85c \uc120\uc5b8\ud574\uc11c \uc6f9\ube0c\ub77c\uc6b0\uc800\uc5d0 \ud45c\uc2dc\ud558\ub294\ub370\uc694. \uc5b4\ub5a4 \uc694\uc18c\ub97c \ucc38\uc870\ud558\uae30 \uc704\ud574 useRef \ud6c5\uc744 \uc0ac\uc6a9\ud569\ub2c8\ub2e4. \uadf8\ub7f0\ub370 \ucc98\uc74c \ucef4\ud3ec\ub10c\ud2b8\uac00 \ub9c8\uc6b4\ud2b8 \ub420\ub54c useRef\ub85c \ucc38\uc870\ud558\uace0\uc790 \ud558\ub294 \uc694\uc18c\uac00 \uc544\uc9c1 \ucc38\uc870\ub418\uc9c0 \uc54a\uc744 \ub54c\uac00 \uc788\uc2b5\ub2c8\ub2e4. \uc774\ub7f4 \ub54c useRef\ub85c \uc5b4\ub5a4 \uc694\uc18c\uac00 \uc81c\ub300\ub85c \ucc38\uc870\ub420 \ub54c \ub2e4\uc2dc \ucef4\ud3ec\ub10c\ud2b8\ub97c \ub80c\ub354\ub9c1\ud574 \uc904 \ud544\uc694\uac00 \uc788\ub294\ub370\uc694. import { OrbitControls } from &#8220;@react-three\/drei&#8221; import { useRef, &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.gisdeveloper.co.kr\/?p=13951\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;useRef\ub85c \uc694\uc18c\uac00 \ucc38\uc870\ub420 \ub54c \ub2e4\uc2dc \ucef4\ud3ec\ub10c\ud2b8 \ub80c\ub354\ub9c1\ud558\uae30&#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-13951","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\/13951","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=13951"}],"version-history":[{"count":6,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/13951\/revisions"}],"predecessor-version":[{"id":13965,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/13951\/revisions\/13965"}],"wp:attachment":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=13951"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=13951"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=13951"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}