Loaders - ObjectLoaders and other example loaders giving TypeError in react-native
See original GitHub issue[TypeError: undefined is not an object (evaluating ‘response.body.getReader’)]
Above error is produced when load function of any loader ( like GLTFLoader or ObjectLoader ) is called.
Platforms tested on:
Mobile - iPhone OS: iOS, MacOS Three.js version 0.135.0 expo-three version 6.0.1 expo-gl version 11.0.3 expo version 43.0.2 react version 17.0.1 react-native version 0.64.3
Sample Code:
const asset = Asset.fromModule(
require("./assets/v_knife_karam/v_knife_karam.gltf")
);
await asset.downloadAsync();
const loader = new GLTFLoader();
loader.load(
asset.uri,
(gltf) => {
// model = gltf.scene;
scene.add(gltf.scene);
},
(xhr) => {
console.log(`${(xhr.loaded / xhr.total) * 100}% loaded`);
},
(error) => {
console.error("An error happened", error);
}
);
Error : [TypeError: undefined is not an object (evaluating ‘response.body.getReader’)]
Issue Analytics
- State:
- Created 2 years ago
- Comments:17 (10 by maintainers)
Top Results From Across the Web
React Native Three js expo-three : Example Model Loaders ...
React Native Three js expo-three : Example Model Loaders giving [TypeError: undefined is not an object (evaluating 'response.body.
Read more >You May need additional loader to handle the result of these ...
Here's my workaround for this one (create-react-app, latest react-leaflet). Hopefully useful for someone stumbling on the issue as well. The ...
Read more >React Native Expo threejs Loaders error while loading 3D ...
React Native Expo threejs Loaders error while loading 3D models ... but all giving the same " TypeError: undefined is not an object...
Read more >Loaders - webpack
Loaders are transformations that are applied to the source code of a module. They allow you to pre-process files as you import or...
Read more >ActivityIndicator - React Native
Displays a circular loading indicator. Example. Function Component; Class Component. ActivityIndicator Function Component Example.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I think it’s more accurate to say that three.js made a change that exposed a bug in react-native / the polyfill. In terms of the benefits of the change the fetch implementation simplified the handling of data URIs in the FileLoader, is easier to follow, and personally I’d like to see Loaders take a set of fetch options in the future considering how much more ergonomic they are.
Have you created an issue for react-native, then? Again this is clearly a shortcoming of these other packages and limits the broader js ecosystems ability to leverage stable, modern APIs. Asking libraries to stall modernization to support workarounds for issues in other packages with no plan or effort to alleviate it is hard to support.
What I’m really asking for is for some effort to be made to fix the fetch polyfill and react native here instead of expecting three.js to revert because it’s the easy way out. I think instead this effort is best spent making a PR for github fetch to fix the
res.arrayBuffer
issue and informing or making a PR for react-native to improve the fetch behavior if that’s needed there too. Seeing what kind of progress can or can’t be made on either project I’d think would better inform decision made by three.js.And to be clear – like I’ve said before – this ultimately isn’t up to me but these are my opinions.
three.js
does not officially support node environments. As mentioned in the documentation (section Node.js), the engine is designed for the web and relies on Web APIs which are not necessarily supported in node.js.That said, we try make a node integration easier with PRs like #10732 or #14914 but only if the changes do not affect the code base too much.
In this particular case, the issue needs to be solved elsewhere like mentioned in https://github.com/mrdoob/three.js/issues/23015#issuecomment-994251807.