import { useRef } from 'react';
import * as everforest from '../_everforest.module.scss'
import { RigidBody } from '@react-three/rapier';
import { useGLTF } from '@react-three/drei';

const terrainModelURL = new URL('../assets/terrain.glb', import.meta.url).href

export default function Ground() {
    const meshRef = useRef();
    const { nodes } = useGLTF(terrainModelURL);
    
    return (
        <RigidBody type='fixed' colliders="trimesh">
            <mesh ref={meshRef} position={[0, 0, 0]} rotation={[-Math.PI / 2, 0, 0]} geometry={nodes.Plane.geometry} name='ground'>
                <meshStandardMaterial color={everforest.yellow}/>
            </mesh>
        </RigidBody>
    );
}
