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

import obj model error when testing on IOS and Anroid #3390

Open Nope-Ry opened 2 weeks ago

Nope-Ry commented 2 weeks ago

Similar to #3085 I encounter the same question when loading obj file. The model can be viewed in web, but not in IOS. Followed my code,

function Model() {
  const [modelPath, setModelPath] = useState<string | null>(null);

  useEffect(() => {
    async function loadModel() {
      try {
        const asset = Asset.fromModule(require("../../assets/models/male.obj"));
        await asset.downloadAsync();
        setModelPath(asset.uri);
      } catch (error) {
        console.log(error);
      }
    }
    loadModel();
  }, []);

  const obj = modelPath ? useLoader(OBJLoader, modelPath) : null;

  return obj ? <primitive object={obj} /> : null;
}

I have found that this error was from the incompatible of ES5 and ES6, when decoding the model file will somehow change from a string to object. How should I fix this?