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.

create texture from camera roll dynamically

See original GitHub issue

Not sure how to approach this, tried:

const pickedImage = await ImagePicker.launchImageLibraryAsync({
  base64: true,
  allowsEditing: false
});

if (pickedImage.cancelled) { return; }

const base64 = "data:image/jpeg;base64," + pickedImage.base64;
const uri = pickedImage.uri.replace("file://", "");
const file = pickedImage.uri;

const texture1 = await ExpoTHREE.createTextureAsync(base64); // error
const texture2 = await ExpoTHREE.createTextureAsync(uri); // error
const texture3 = await ExpoTHREE.createTextureAsync(file); // error
const texture4 = THREE.ImageUtils.loadTexture(base64); // white mesh
const texture5 = THREE.ImageUtils.loadTexture(uri);  // white mesh

const geometry = new THREE.PlaneGeometry(0.1, 0.1);
const material = new THREE.MeshLambertMaterial({
  map: texture // 1..5
});
const mesh = new THREE.Mesh(geometry, material);
mesh.position.z = -0.1;

this.scene.add(mesh);

Nothing seems to work 😃

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
EvanBaconcommented, Mar 1, 2018

Base64 is not supported in EXGL texture rendering at the moment. The ImagePicker returns a uri that is formatted differently than other things, this will be fixed with a new version of expo-asset-utils. This issue tracks that: https://github.com/expo/expo-asset-utils/issues/1

0reactions
EvanBaconcommented, May 31, 2018

I would just recommend not using Base64. It’s really pricey to move over the bridge and there are ways to convert it to a localUri that would be just as expensive as incorporating it directly into the method. Let me know if I’m missing something here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create Texture Dynamically From Camera View... Possible?
I want to map what a camera in my scene is seeing onto the surface of an object that my main camera is...
Read more >
How To Create Dynamic Textures with CCRenderTexture in ...
Learn how to create dynamic textures similar to the hills in Tiny Wings using CCRenderTexture in this Cocos2D 2.X Tutorial.
Read more >
Creating RenderTexture at runtime
Hi all, I'm testing a 360° screen view with 10 cameras. All cams are build from one with 'Instantiate' function and it works...
Read more >
Gallery Texture and Gallery Picker - Spark AR
The gallery picker lets people add an image from their phone's camera roll to an effect, like a green screen. To create an...
Read more >
UE4 Material Tricks you didn't know - YouTube
I had an issue on the Face Camera part that I've already figured out ... UV Clamping 0:17:26 - Texture Projection - Screen...
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