Closed Dukeyeboah closed 2 months ago
Thanks @Dukeyeboah , the translation()
should be correct.
Giving if (body.current) console.log(body.current.translation())
like so:
//SUN COMPONENT const Sun = () => {
const sunMaterialRef = useRef(); const sun = useRef();
useFrame((state, delta) => { const elapsedTime = state.clock.getElapsedTime();
if (sun.current) console.log(sun.current.translation())
});
return ( <> <mesh ref={sun} scale={[0.25, 0.25, 0.25]} geometry={sunGeometry}
</>
); };
export default Sun;
Is this appropriate? because i'm getting the following console error:
Sun.jsx:59 Uncaught TypeError: sun.current.translation is not a function at Object.current (Sun.jsx:59:46) at render$1 (chunk-YZGFH4DN.js?v=3142cbc5:17095:22) at loop (chunk-YZGFH4DN.js?v=3142cbc5:17116:19)
You need to assign the ref to <Ecctrl ref={sun} />
Thank you that makes sense. It works.
I love this library and it's working great for me with the project i'm building. However I want to be able to access my meshes position / translation information to know its coordinates. So that if it falls for example, I can reload t=it back to its initial positoin. However I can't seem to get access to this data, is there a way to get this ?
Where my mesh has I tried using body.current.position, in useFrame, but the vector coordinates of the position don't update when I move around. I also tried using body.current.translation() but there was an error