import obj model error when testing on IOS and Anroid
Closed this issue · 1 comments
Nope-Ry commented
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 commented
what does you metro config look like ?