How to load a remote obj file with ExpoTHREE?


#1

Hi I am trying to use Poly API (https://developers.google.com/poly/) with Expo Three. How do you load a remote obj file? Is it a combination of FileSystem.downloadAsync and ExpoTHREE.loadAsync? I have the filesystem part down, but I don’t know how to use the returned uri (file:///var/mobile/Containers/Data/Application/…/Documents/ExponentExperienceData/…/model.obj) with ExpoTHREE.loadAsync since it needs a require(something) for the third argument.

EDIT:
Here is my source to get a better idea: https://github.com/ethantran/react-native-examples/blob/arkit/src/screens/ARExample.js#L299

EDIT:
ExpoTHREE.loadAsync partially works with remote urls. The model loaded but it was all black.
const mesh = await ExpoTHREE.loadAsync( [ objFormat.root.url, ...objFormat.resources.map(resource => resource.url) ], this.handleLocalDownload );

I was able to load a remote obj file with color using the simplest way.
var urlOBJ = objFormat.root.url; var urlMTL = objFormat.resources[0].url; var mtlloader = new THREE.MTLLoader(); mtlloader.load( urlMTL, mats => { var objloader = new THREE.OBJLoader(); objloader.setMaterials(mats); objloader.load( urlOBJ, mesh => { this.addCustomDestination({ mesh }); this.setState({ polySelection: { mesh }, showDownloadProgress: false }); }, this.handleLocalDownload ); }, this.handleLocalDownload );