pmndrs / react-three-fiber

🇨🇭 A React renderer for Three.js
https://docs.pmnd.rs/react-three-fiber
MIT License
27.62k stars 1.6k forks source link

Error: Could not load Car.fbx: Call to function 'ExpoAsset.downloadAsync' has been rejected. #3383

Open ahazem-dev opened 4 weeks ago

ahazem-dev commented 4 weeks ago

Complete error message

 (NOBRIDGE) ERROR  Error: Could not load Car.fbx: Call to function 'ExpoAsset.downloadAsync' has been rejected.
→ Caused by: Unable to download asset from url: Car.fbx

My code looks like

import { OrbitControls, useFBX } from '@react-three/drei/native';
import { Canvas } from '@react-three/fiber/native';

// Load FBX Model Function
function CarModel() {
  const fbx = useFBX('Car.fbx')
  return <primitive object={fbx} scale={0.01} />;
}

export default function CanvasView() {
  return (
    <Canvas style={{ flex: 1 }}>
      {/* Add ambient light and directional light */}
      <ambientLight intensity={0.3} />
      <directionalLight position={[10, 10, 10]} intensity={1.5} />

      {/* <Suspense fallback={<Loader/>}> */}
        {/* Load the FBX model */}
        <CarModel />
      {/* </Suspense> */}

      {/* Orbit controls to rotate/zoom the model */}
      <OrbitControls enableZoom={true} />
    </Canvas>
  );
}

Component location and model location are: Screenshot 2024-10-23 at 5 27 23 PM

The result on an emulator is:

Screenshot 2024-10-23 at 5 30 41 PM

Assets extension in metro.config.js are: Screenshot 2024-10-23 at 5 33 39 PM

what can be the problem? if you do not understand any of the points, please ask follow-up questions