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.

LoadTextureAsync not working with standalone app

See original GitHub issue

Hi I’m realizing a project where I have to realize a 3D earth with Expo-THREE but i would like to give a texture to my sphere . However, I only achieved this on development but with a standalone app (android) the texture doesn’t download. I have a black sphere. On IOS, everything goes well in development and with Testfligt app. I do like that to render my sphere :

const terre = require("../../../../assets/images/panorama.png")    
    scene = new THREE.Scene();
    const light = new THREE.DirectionalLight(new THREE.Color(0xffffff), 1);
    light.position.set(6, 6, 8);
    scene.add(light)
    camera = new THREE.PerspectiveCamera(
      75,
      gl.drawingBufferWidth / gl.drawingBufferHeight,
      0.1,
      1000
    );
    renderer = new ExpoTHREE.Renderer({ gl });
    renderer.setSize(gl.drawingBufferWidth, gl.drawingBufferHeight);

    const texture = await ExpoTHREE.loadTextureAsync({asset: terre})
    const geometry = new THREE.SphereBufferGeometry(GLOBE_RADIUS, 128, 128);
    const material = await new THREE.MeshLambertMaterial({
      map: texture
    });
    const sphere = new THREE.Mesh(geometry, material);
    scene.add(sphere);
    camera.position.set(6, 6, 8);

I also tried to replace my local uri by a picture online but i had the same issue as before.

I also try to realize this issue :

but after tried this , the result was the same for the standalone app.

My config file :

App.json : { “expo”: { “name”: “name”, “slug”: “name-app”, “privacy”: “public”, “sdkVersion”: “32.0.0”, “platforms”: [ “ios”, “android” ], “version”: “2.0.0”, “orientation”: “portrait”, “icon”: ./launcher.png", “splash”: { “image”: “./splash.png”, “resizeMode”: “contain”, “backgroundColor”: “#ffdc00” }, “updates”: { “fallbackToCacheTimeout”: 0 }, “assetBundlePatterns”: [ “/" ], “android”: { “package”: "org..***”, “versionCode”: 23, “googleServicesFile”: “./google-services.json”, “permissions”: [ “ACCESS_COARSE_LOCATION”, “ACCESS_FINE_LOCATION”, “CAMERA”, “READ_CONTACTS” ] } } }

Mon Package.json : { “main”: “node_modules/expo/AppEntry.js”, “scripts”: { “start”: “expo start”, “android”: “expo start --android”, “ios”: “expo start --ios”, “eject”: “expo eject” }, “dependencies”: { “d3-geo”: “^1.11.3”, “expo”: “^32.0.0”, “expo-asset-utils”: “^1.0.0”, “expo-face-detector”: “^4.0.0”, “expo-graphics”: “^1.0.3”, “expo-three”: “^3.0.0-alpha.8”, “react”: “16.5.0”, “react-native”: “https://github.com/expo/react-native/archive/sdk-32.0.0.tar.gz”, “three”: “^0.96.0” }, “devDependencies”: { “babel-preset-expo”: “^5.0.0” }, “private”: true }

Can you tell me what can I do ? Thanks a lot !

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:6
  • Comments:10

github_iconTop GitHub Comments

4reactions
bonbertrcommented, Jun 5, 2019

Hello, I work with @Trancoso and was able to find a workaround for our problem. Using adb logcat with a production build and logging the texture returned by ExpoTHREE.loadAsync I noticed that the asset localUri started with asset://. Then using https://github.com/expo/expo/issues/2693#issuecomment-488631357 to get a file:// uri for my asset, I overwrote the texture image localUri with the uri. So far it works fine. Here is the code:

const uri =  await this.copyAssetToCacheAsync(require('../../../../assets/images/panorama.png'),'panorama.png');
  const texture = await ExpoTHREE.loadAsync(uri);
  texture.image.data.localUri = texture.image.data.uri;
  const material = new THREE.MeshBasicMaterial({
    map: texture
  });

  const geometry = new THREE.SphereBufferGeometry(GLOBE_RADIUS, 128, 128);
  const sphere = new THREE.Mesh(geometry, material);
  scene.add(sphere);

Where copyAssetToCacheAsync function is the one provided by adbl in the linked issue.

0reactions
ssdenis00commented, Sep 15, 2022

you need to change the file resolution. For example “test1.png” to “test1.xpng” or "test2.jpg " on “test2.xjpg”.

const texture = await ExpoTHREE.loadTextureAsync({asset: require(‘…/…/…/…/assets/images/panorama.xpng’)}); const material = new THREE.MeshBasicMaterial({ map: texture });

const geometry = new THREE.SphereBufferGeometry(GLOBE_RADIUS, 128, 128); const sphere = new THREE.Mesh(geometry, material); scene.add(sphere);

work for me sdk44 react-native 0.64.0

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't Load Obj Model With Textures Using Expo-Three
LoadTextureAsync not working with standalone app #104 drawingBufferHeight; ... The issue is that model is loading without textures and it looks something ...
Read more >
getExpoPushTokenAsync not working on Standalone app
I had similar problem and I solved it by enabling my notification for Expo client on my device. Share. Share a link to...
Read more >
Asynchronous Texture Upload - Unity - Manual
Asynchronous Texture Upload enables asynchronous loading of Texture Data ... or loading from the Resources folder, the Asynchronous buffer loading is not ......
Read more >
Load resources in your DirectX game - UWP - Microsoft Learn
This sample also includes three code files for resource loading and ... This flag will keep track of whether or not all application...
Read more >
Standalone: Android Facebook Auth never returns from com ...
Using expo-auth-session , not expo-facebook . Only happens on standalone build, on Android. The Problem. What happens? When the facebook app is ...
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