expo-three
expo-three copied to clipboard
texture based on file:// url won't load
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
Try passing textureLoader.load
the asset
instead of asset.localUri
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);
}
});
}
}
@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)
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: https://github.com/expo/expo-three/pull/301/commits/e9f0a1d6504f737d703647dd6dec1dc64b562af8