import React, { useEffect, useRef } from 'react'; import { useGLTF } from '@react-three/drei'; import Charater from '../../assets/Character/Character.glb'; function Model({ position }) { const group = useRef(); const d = useGLTF(Charater); console.log("nodes",d) useEffect(() => { if (d.scene) { // Locate the eyes in the scene hierarchy const leftEye = d.scene.getObjectByName('EyeRight'); // Replace 'LeftEye' with the actual name const rightEye = d.scene.getObjectByName('Wolf3D_Hair'); // Replace 'RightEye' with the actual name if (leftEye) leftEye.visible = false; // Hide the left eye if (rightEye) rightEye.visible = false; // Hide the right eye if (leftEye) leftEye.position.set(1, 0.5, 0); // Example: Move left eye //if (rightEye) rightEye.position.set(-1, 0.5, 0); // Example: Move right eye } }, [d.scene]); return (
import React, { useEffect, useRef } from 'react';
import { useGLTF } from '@react-three/drei';
import Charater from '../../assets/Character/Character.glb';
function Model({ position }) {
const group = useRef();
const d = useGLTF(Charater);
console.log("nodes",d)
useEffect(() => {
if (d.scene) {
// Locate the eyes in the scene hierarchy
const leftEye = d.scene.getObjectByName('EyeRight'); // Replace 'LeftEye' with the actual name
const rightEye = d.scene.getObjectByName('Wolf3D_Hair'); // Replace 'RightEye' with the actual name
if (leftEye) leftEye.visible = false; // Hide the left eye
if (rightEye) rightEye.visible = false; // Hide the right eye
if (leftEye) leftEye.position.set(1, 0.5, 0); // Example: Move left eye
//if (rightEye) rightEye.position.set(-1, 0.5, 0); // Example: Move right eye
}
}, [d.scene]);
return (
);
}
export default Model;