import { useGLTF, ContactShadows } from ‘@react-three/drei’;
import { useEffect, useRef } from “react”;
import { Environment, OrbitControls, useHelper } from ‘@react-three/drei’;
import { Group,PerspectiveCamera, SpotLight ,DirectionalLight} from “three”;
const Model = () => {
console.log(“mainscene”)
const gltf = useGLTF(‘src/assets/model/GirlLoop.glb’);
const group = useRef()
gltf.scene.traverse( function( node ) {
if ( node.isMesh ) { node.castShadow = true; }
} );
const camera = new PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000)
useEffect(() => {
gltf.scene.traverse((child) => {
if (child.isMesh) {
child.castShadow = true;
}
});
}, [gltf.scene]);
useEffect(() => {
camera.position.set(5,5,5)
camera.lookAt(0,-3.5,-0.2)
}, [camera]);
return (<>
<OrbitControls
enableZoom={true}
maxDistance={15}
minDistance={1}
minAzimuthAngle={-Math.PI / 8} // Limit to 45 degrees to the left
maxAzimuthAngle={Math.PI / 8}
/>
<primitive object={gltf.scene} ref={group} scale={[0.8, 0.8, 0.8]} position={[0,-2,-0.16]} rotation={[0, -Math.PI / 2, 0]} castShadow/>
<directionalLight position={[2,3,-0.16]} intensity={5} castShadow shadow-mapSize-width={1024}
shadow-mapSize-height={1024}
/>
<ambientLight intensity={1}/>
<ContactShadows position={[0,-2,-0.16]} rotation={[0,-Math.PI/2,0]} scale={0.8} opacity={0.1} blur={0.5} color='black'/>
</>
);
}
export default Model;