Skip to content
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

texture based on file:// url won't load #297

Open
earonesty opened this issue Jul 28, 2023 · 4 comments
Open

texture based on file:// url won't load #297

earonesty opened this issue Jul 28, 2023 · 4 comments

Comments

@earonesty
Copy link

earonesty commented Jul 28, 2023

followed this documentation:

https://github.com/expo/expo-three#loading-assets

texture based on remote image won't load:

  • used expo-asset to create and download asset
  • asset.localUri is downloaded, returns a "file://" url
  • TextureLoader().load(asset.localUri) throws an error:
Call to function 'ExponentFileSystem.downloadAsync' has been rejected.
→ Caused by: java.lang.IllegalArgumentException: Expected URL scheme 'http' or 'https' but was 'file'
    at construct (native)
    at apply (native)
    at _construct (http://10.24.121.64:8081/node_modules%5Cexpo%5CAppEntry.bundle//&platform=android&dev=true&hot=false&lazy=true:4486:28)
    at Wrapper (http://10.24.121.64:8081/node_modules%5Cexpo%5CAppEntry.bundle//&platform=android&dev=true&hot=false&lazy=true:4448:25)
    at construct (native)
    at _createSuperInternal (http://10.24.121.64:8081/node_modules%5Cexpo%5CAppEntry.bundle//&platform=android&dev=true&hot=false&lazy=true:125092:322)
    at call (native)
    at CodedError (http://10.24.121.64:8081/node_modules%5Cexpo%5CAppEntry.bundle//&platform=android&dev=true&hot=false&lazy=true:125105:26)

i believe this has already been fixed in dependent libs, so you just have to update deps

@earonesty earonesty changed the title texture based on remote image won't load texture based on file:// url won't load Jul 28, 2023
@louix
Copy link

louix commented Nov 16, 2023

Try passing textureLoader.load the asset instead of asset.localUri

@markrickert
Copy link
Contributor

markrickert commented Mar 22, 2024

I had this problem today with the latest expo-asset.

Try this:

class LocalIconMesh extends Mesh {
  constructor() {
    super();
    this.geometry = new BoxGeometry(1, 1, 1);
    const loader = new TextureLoader();
    Asset.loadAsync(require('../assets/icon.png')).then(([{ localUri }]) => {
      try {
        loader.load(localUri, (texture) => {
          this.material = new MeshBasicMaterial({ map: texture });
        });
      } catch (error) {
        console.error(error);
      }
    });
  }
}

@orange4glace
Copy link

orange4glace commented Apr 15, 2024

@markrickert Thanks for your work. BTW, I think your code is for loading texture from its own package. How can I load a texture from FileSystem? (ex: pick an image from gallery)

@markrickert
Copy link
Contributor

Hi @orange4glace, sorry for the late reply. I just added an example in my updated fork. Everything is up to date in my implementation with three 0.166.0 and expo sdk 51.

I added a demo of how to use local file paths via an image picker to the "bouncing balls" demo of my fork. You can check it out here: e9f0a1d

33DEA067-EE35-42B8-8F07-23C77BB7BB75-99740-000649283FF60264

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants