Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Nope-Ry opened this issue Nov 5, 2024 · 1 comment
Closed

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

Nope-Ry opened this issue Nov 5, 2024 · 1 comment

Comments

@Nope-Ry
Copy link

Nope-Ry commented Nov 5, 2024

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?

@jb-san
Copy link

jb-san commented Nov 23, 2024

what does you metro config look like ?

@Nope-Ry Nope-Ry closed this as completed Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants