I learning three now and i had error. This my problem :
Error: R3F: Hooks can only be used within the Canvas component!
My code:
import React from 'react';
import { useSnapshot } from 'valtio';
import { useGLTF, useTexture, Decal } from '@react-three/drei';
import state from '../store';
import { useFrame } from '@react-three/fiber';
const Shirt = () => {
const snap = useSnapshot(state);
const { nodes, materials } = useGLTF('/shirt_baked.glb');
const logoTexture = useTexture(snap.logoDecal);
const fullTexture = useTexture(snap.fullDecal);
return (
<mesh
castShadow
geometry={nodes.T_Shirt_male.geometry}
material={materials.lambert1}
material-roughness={1}
dispose={null}
></mesh>
);
};
export default Shirt;
How i decide this problem?
Learning three js…