-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Issue with Loading OBJ File using OBJLoader in React Native #3085
Comments
Seems that loaders internally are not creating the correct response type. The following is what #3086 should do: function Box() {
const buffer = useLoader(THREE.FileLoader, require('./assets/tableau.obj'));
const obj = useMemo(() => new OBJLoader().parse(THREE.LoaderUtils.decodeText(buffer)), [buffer])
return <primitive object={obj} scale={10} />
} |
I have another error with this code, More informations : |
Hi, has this been solved already? I'm having the same issues with you. Please let me know if that has been resolved already. Thanks! |
Hello? |
I have a workaround you can try in #3085 (comment). function Box() {
const buffer = useLoader(THREE.FileLoader, require('./assets/tableau.obj'));
const obj = useMemo(() => new OBJLoader().parse(THREE.LoaderUtils.decodeText(buffer)), [buffer])
return <primitive object={obj} scale={10} />
} I also have a PR that would fix this issue, but it needs better integration testing since I'm already seeing fail cases with {
"dependencies": {
"@react-three/fiber": "https://pkg.csb.dev/pmndrs/react-three-fiber/commit/a689a1f9/@react-three/fiber"
}
} |
Thanks! |
Was able to use obj assets with this snippet:
Hope it works for you too. |
actually worked for me. |
I have the same issue now. But the code from @expolli didn't work :(. Any suggestions ?
|
What is the issue exactly? Do neither of these work also? I'll look into getting #3086 out, but it may not be enough on its own. // https://github.com/pmndrs/react-three-fiber/issues/3085#issuecomment-1837583297
function A() {
const buffer = useLoader(THREE.FileLoader, require('./assets/tableau.obj'));
const obj = useMemo(() => new OBJLoader().parse(THREE.LoaderUtils.decodeText(buffer)), [buffer])
return <primitive object={obj} scale={10} />
}
// Likely indicates a deeper regression since the start of the thread
// https://github.com/pmndrs/react-three-fiber/issues/3085#issuecomment-1925877969
import { Asset } from 'expo-asset'
function B() {
const buffer = useLoader(THREE.FileLoader, Asset.fromModule(require('./assets/Airmax/shoe.obj')).uri);
const obj = useMemo(() => new OBJLoader().parse(THREE.LoaderUtils.decodeText(buffer)), [buffer])
return <primitive object={obj} scale={10} />
} |
Do you know will this work also if you want to add the material / load a material ? function A() { Looks like this example works. Thank you @CodyJasonBennett |
That example should work until #3086 is merged which lets the normal |
I encountered an issue while using the OBJLoader library from Three.js to load an OBJ file in a React Native application. I placed the OBJ file in the assets directory of my React Native project and I'm trying to load it using useLoader from the @react-three/fiber/native library.
I get the following error:
Error: Could not load 2: text.indexOf is not a function (it is undefined)
which comes from the lineconst obj = useLoader(OBJLoader, require('./assets/tableau.obj'));
My code :
The text was updated successfully, but these errors were encountered: