{"id":14142,"date":"2023-09-03T17:53:02","date_gmt":"2023-09-03T08:53:02","guid":{"rendered":"http:\/\/www.gisdeveloper.co.kr\/?p=14142"},"modified":"2023-10-03T17:59:37","modified_gmt":"2023-10-03T08:59:37","slug":"skinedmesh%ec%9d%98-clone","status":"publish","type":"post","link":"http:\/\/www.gisdeveloper.co.kr\/?p=14142","title":{"rendered":"SkinedMesh\uc758 Clone"},"content":{"rendered":"<p>\uc560\ub2c8\uba54\uc774\uc158 \ubaa8\ub378 \ub9ac\uc18c\uc2a4\ub85c\ubd80\ud130 \uac00\uc838\uc628 \ub370\uc774\ud130\ub97c \uc5ec\ub7ec\uac1c \ubcf5\uc0ac\ud574\uc11c \uc0ac\uc6a9\ud558\uace0\uc790 \ud560\ub54c \ud544\uc694\ud55c \ucf54\ub4dc\uc785\ub2c8\ub2e4.<\/p>\n<p>1\uac1c\ub9cc \uc0ac\uc6a9\ud560\ub54c\ub294 \ubb38\uc81c\uac00 \uc5c6\ub294 \uae30\ubcf8\uc801\uc73c\ub85c \uc791\uc131\ub41c \ucf54\ub4dc\ub294 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"jsx\">\r\nimport React, { useEffect, useMemo, useRef, useState } from 'react'\r\nimport { useGLTF, useAnimations } from '@react-three\/drei'\r\nimport * as THREE from \"three\"\r\n\r\nexport function Robot({ color = \"gray\", ...props }) {\r\n  const group = useRef()\r\n  const { nodes, materials, animations } = useGLTF('\/Robot.glb')\r\n  const { actions } = useAnimations(animations, group)\r\n  const [ animation, setAnimation ] = useState(\"Idle\")\r\n\r\n  useEffect(() => {\r\n    actions[animation].reset().fadeIn(0.5).play()\r\n    return () => actions[animation].fadeOut(0.5)\r\n  }, [ animation ])\r\n\r\n  materials.Alpha_Body_MAT.color = new THREE.Color(color)\r\n\r\n  return (\r\n    &lt;group ref={group} {...props} dispose={null}>\r\n      &lt;group name=\"Scene\">\r\n        &lt;group name=\"Armature\" rotation={[Math.PI \/ 2, 0, 0]} scale={0.01}>\r\n          &lt;primitive object={nodes.mixamorigHips} \/>\r\n          &lt;skinnedMesh name=\"Alpha_Joints\" geometry={nodes.Alpha_Joints.geometry} material={materials.Alpha_Joints_MAT} skeleton={nodes.Alpha_Joints.skeleton} \/>\r\n          &lt;skinnedMesh name=\"Alpha_Surface\" geometry={nodes.Alpha_Surface.geometry} material={materials.Alpha_Body_MAT} skeleton={nodes.Alpha_Surface.skeleton} \/>\r\n        &lt;\/group>\r\n      &lt;\/group>\r\n    &lt;\/group>\r\n  )\r\n}\r\n\r\nuseGLTF.preload('\/Robot.glb')\r\n<\/pre>\n<p>\uc704\uc758 \ucf54\ub4dc\uc5d0 \ub300\ud55c \ubaa8\ub378 \uc5ec\ub7ec\uac1c\ub97c \uc7a5\uba74\uc5d0 \ucd94\uac00\ud558\uae30 \uc704\ud574 \ub2e4\uc74c\ucc98\ub7fc \ucf54\ub4dc\ub97c \uc218\uc815\ud574\uc57c \ud569\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"jsx\">\r\nimport React, { useEffect, useMemo, useRef, useState } from 'react'\r\nimport { useGLTF, useAnimations } from '@react-three\/drei'\r\nimport * as THREE from \"three\"\r\nimport { useGraph } from '@react-three\/fiber'\r\nimport { SkeletonUtils } from \"three-stdlib\"\r\n\r\nexport function Robot({ color = \"gray\", ...props }) {\r\n  const group = useRef()\r\n  const { scene, materials, animations } = useGLTF('\/Robot.glb')\r\n  const clone = useMemo(() => SkeletonUtils.clone(scene), [scene])\r\n  const { nodes } = useGraph(clone)\r\n  const { actions } = useAnimations(animations, group)\r\n  const [ animation, setAnimation ] = useState(\"Idle\")\r\n\r\n  useEffect(() => {\r\n    actions[animation].reset().fadeIn(0.5).play()\r\n    return () => actions[animation].fadeOut(0.5)\r\n  }, [ animation ])\r\n\r\n  const material = materials.Alpha_Body_MAT.clone()\r\n  material.color = new THREE.Color(color)\r\n\r\n  return (\r\n    &lt;group ref={group} {...props} dispose={null}>\r\n      &lt;group name=\"Scene\">\r\n        &lt;group name=\"Armature\" rotation={[Math.PI \/ 2, 0, 0]} scale={0.01}>\r\n          &lt;primitive object={nodes.mixamorigHips} \/>\r\n          &lt;skinnedMesh name=\"Alpha_Joints\" geometry={nodes.Alpha_Joints.geometry} material={materials.Alpha_Joints_MAT} skeleton={nodes.Alpha_Joints.skeleton} \/>\r\n          &lt;skinnedMesh name=\"Alpha_Surface\" geometry={nodes.Alpha_Surface.geometry} material={material} skeleton={nodes.Alpha_Surface.skeleton} \/>\r\n        &lt;\/group>\r\n      &lt;\/group>\r\n    &lt;\/group>\r\n  )\r\n}\r\n\r\nuseGLTF.preload('\/Robot.glb')\r\n<\/pre>\n<p>\uc704\uc758 \ucf54\ub4dc\uc5d0\uc11c SkeletonUtils\ub97c \uc0ac\uc6a9\ud558\uace0 \uc788\ub294\ub370 \uc774\ub97c \uc704\ud574 \uc544\ub798\uc758 \ucf54\ub4dc\ub97c \uc2e4\ud589\ud558\uc5ec three-stdlib\ub97c \uc124\uce58\ud574\uc57c \ud569\ub2c8\ub2e4.<\/p>\n<p><code>npm i three-stdlib<\/code><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uc560\ub2c8\uba54\uc774\uc158 \ubaa8\ub378 \ub9ac\uc18c\uc2a4\ub85c\ubd80\ud130 \uac00\uc838\uc628 \ub370\uc774\ud130\ub97c \uc5ec\ub7ec\uac1c \ubcf5\uc0ac\ud574\uc11c \uc0ac\uc6a9\ud558\uace0\uc790 \ud560\ub54c \ud544\uc694\ud55c \ucf54\ub4dc\uc785\ub2c8\ub2e4. 1\uac1c\ub9cc \uc0ac\uc6a9\ud560\ub54c\ub294 \ubb38\uc81c\uac00 \uc5c6\ub294 \uae30\ubcf8\uc801\uc73c\ub85c \uc791\uc131\ub41c \ucf54\ub4dc\ub294 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4. import React, { useEffect, useMemo, useRef, useState } from &#8216;react&#8217; import { useGLTF, useAnimations } from &#8216;@react-three\/drei&#8217; import * as THREE from &#8220;three&#8221; export function Robot({ color = &#8220;gray&#8221;, &#8230;props }) { const group = &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.gisdeveloper.co.kr\/?p=14142\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;SkinedMesh\uc758 Clone&#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-14142","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\/14142","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=14142"}],"version-history":[{"count":3,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/14142\/revisions"}],"predecessor-version":[{"id":14145,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/14142\/revisions\/14145"}],"wp:attachment":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=14142"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=14142"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=14142"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}