question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

createTextureAsync from remote dynamic image file

See original GitHub issue

Images can be loaded as a material using code like the following:

const img = require('./assets/images/myImage.jpg'); 
const material = new THREE.MeshBasicMaterial({
   map: await ExpoTHREE.createTextureAsync({
     asset: Expo.Asset.fromModule(img),
   })
});

How can we create a material from a remote file determined at runtime (where require() is not available) and we cannot create an Expo.Asset?

Here are some attempts I’ve made, with no luck:

var expoAsset = new Expo.Asset();
expoAsset.uri = "https://s3.amazonaws.com/exp-brand-assets/ExponentEmptyManifest_192.png";
const material = new THREE.MeshBasicMaterial({
   map: await ExpoTHREE.createTextureAsync({
     asset: expoAsset
   })       
});


var textureLoader = new THREE.TextureLoader();
textureLoader.load("https://s3.amazonaws.com/exp-brand-assets/ExponentEmptyManifest_192.png", function(loadedTexture) {     
  const material = new THREE.MeshBasicMaterial({ map: loadedTexture });
});  


var loadingManager = new THREE.LoadingManager();
var imageLoader = new THREE.ImageLoader(loadingManager);
imageLoader.load("https://s3.amazonaws.com/exp-brand-assets/ExponentEmptyManifest_192.png", function(image) {
    var texture = new THREE.Texture();
    texture.image = image;
    var material = new THREE.MeshBasicMaterial( {map: texture});        
});

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (5 by maintainers)

github_iconTop GitHub Comments

3reactions
EvanBaconcommented, Dec 8, 2017

@ericmorgan1 just pushed expo-three: 2.0.7.

You can now call:

const someRemoteUrl = "https://www.biography.com/.image/t_share/MTE5NDg0MDU0ODczNDc0NTc1/ben-affleck-9176967-2-402.jpg"
const texture = await ExpoTHREE.loadAsync(someRemoteUrl)

Snack: https://snack.expo.io/@bacon/expo-three-remote-image

0reactions
krjk333commented, Dec 7, 2020

@EvanBacon , How to load the 3d object like this. I tried with so many methods to load an object. All gets failed. Please anyone help me to load 3d object in .obj, .gltf, or .glb any of one format in react native.

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native - Image Require Module using Dynamic Names
First, create a file with image required - React native images must be loaded this way. assets/index.js export const friendsandfoe = require('.
Read more >
Dynamic Image API | Customer's Canvas Dev
Dynamic Image API. BuildInfo. Controller for getting information about the application. ... If true , overwrites the image if its file name already...
Read more >
About dynamic image assets - Google Ads Help
Dynamic image assets are an account level automated asset that allows Google to curate relevant visuals from your ad's landing page to complement...
Read more >
Include live remote image in Beamer presentation - TeX
The remote image will be refreshed every three seconds. ... it recognizes the file suffix; so if you are building dynamic images in...
Read more >
How to load images dynamically? - Google Groups
new Image("path to remote image file here");.. Salvador Diaz's profile photo ... Also note that ImageBundles cannot be generated dynamically as they're
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found