Skip to content

(React Native): Loaders fails with "Cannot read property 'Base64' of undefined" (repro included) #3583

@FranckG28

Description

@FranckG28

Hi !

I've been trying for 3-4 days to import a .glb file in a Canvas using React Native.

After reading the corresponding R3F/three-stdlib codebase and trying anything that I could, I was wondering if it was even working with the minimal example provided in the documentation.

Even this minimal example leads to the same error, directly when useGLTF (or useLoader(GLTFLoader,...)) is called :

Cannot load 1: Cannot read property 'Base64' of undefined [object Object]

Notes:

  • This seems to happen on other loaders too
  • '1' can vary depending on what you provide (e.g. Providing a base64 string glb will print the whole base64 in place of '1').
  • I've ensured that the asset exist and is not null. (loaded it with expo-asset, then read file info with expo-fs).
  • The same minimal repro on web (with Vite instead of expo) works correctly.

Repro steps

  • Created a sample expo app with pnpm create expo-app --template blank-typescript
  • Added three, r3f, drei, expo-gl packages
  • Extending metro config like in r3f doc.
  • Use snippet from doc to load the official minimal GLB file

Minimal reproduction repo

To help demonstrate the problem, I've created a simple repository following the steps I've described above.
https://github.com/FranckG28/r3f-native-gltf-test
Simply clone, run pnpm i && pnpm start, scan QR code with Expo Go to reproduce by yourself

I'm new to the three/r3f ecosystem. I've read most of the codebase of useGLTF (drei) > useLoader (r3f) > GLTFLoader (three-stdlib), but I can't figure out from where this problem could occur.
I'm willing to debug this, but the debugger is detached from the device as soon as the error occur. And the error is occuring even before i can open the debugger ...

Let me know if you have a clue, or it you need other elements from my side.

Thank you R3F team for your Amazing work !

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions