All files / components/three CustomModel.tsx

100% Statements 8/8
66.66% Branches 2/3
100% Functions 2/2
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 261x                     1x 1x 1x   1x 1x 1x       1x        
"use client";
import { useRef } from "react";
import { useFrame } from "@react-three/fiber";
import { useGLTF } from "@react-three/drei";
import * as THREE from "three";
 
interface ModelProps {
  url: string;
  scale?: number;
}
 
const CustomModel = ({ url, scale = 1 }: ModelProps) => {
  const { scene } = useGLTF(url);
  const modelRef = useRef<THREE.Group>(null);
 
  useFrame(() => {
    Eif (modelRef.current) {
      modelRef.current.rotation.y += 0.002; // Slow rotation
    }
  });
 
  return <primitive ref={modelRef} object={scene} scale={scale} />;
};
 
export default CustomModel;