pmndrs / react-three-fiber

🇨🇭 A React renderer for Three.js
https://docs.pmnd.rs/react-three-fiber
MIT License
26.72k stars 1.51k forks source link

Not working with React Native CLI (OBJ & GLTF) #3299

Open mattlewer opened 2 weeks ago

mattlewer commented 2 weeks ago

I've spent the last several hours trying to get this library to work with React Native CLI and haven't managed to get a single custom 3d object rendered, feel like I'm losing it.

Reference to my original bug post (closed to make this one instead, but please reference if needed): https://github.com/pmndrs/react-three-fiber/issues/3298

Initially wanted to render an OBJ file, ran into the same issues posted here where it is admitted that loading a OBJ file does not work properly, the solutions do not work for me either: https://github.com/pmndrs/react-three-fiber/issues/3085 https://github.com/pmndrs/react-three-fiber/issues/3199

Gave up on that and converted it to a GLTF to start from the simplest approach of following the docs. First of all I have a TypeScript error that Property 'scene' does not exist on type 'GLTF | GLTF[]'. when this is what the docs say to do here?: https://docs.pmnd.rs/react-three-fiber/getting-started/installation#react-native:~:text=...props%7D-,object%3D%7Bgltf.scene%7D,-/%3E%0A%7D%0A%0Aexport

Then when I run it I get another error: Error: Could not load 1: THREE.GLTFLoader: Failed to load buffer "model.bin".

I'm honestly at a loss, will provide example repo's so hopefully you can spot the issue here...

mattlewer commented 2 weeks ago

React Native CLI project created showing failures mentioned: https://github.com/mattlewer/ReactFiberDemo

Expo CLI project with similar issues: https://github.com/mattlewer/ReactFiberDemo-Expo

After the original post, I have also now tried the same thing with an Expo Cli project which also gives the same results.

A & B do not error, but I get a warning about decodeText being deprecated, obj returned is logged as the following, but nothing is visible on the screen: {"metadata": {"generator": "Object3D.toJSON", "type": "Object", "version": 4.6}, "object": {"layers": 1, "matrix": [Array], "type": "Group", "up": [Array], "uuid": "ccd3c3b9-db80-4e9b-9678-b1840f7a6a23"}}

C fails with Failed to load buffer "buffer.bin" .

Hopefully having similar issues on both helps to resolve this.