How to set up a dynamic Texture?
Hi!
Saw the post to get dynamic data into lenses. Wondering if there's any way to set up textures in a dynamic way. Either by sharing a JPG in text format or by sharing the URL.
Thanks in advance!
ps. We are applying for the Camera Kit partner program. Maybe there's something we can do to use as an Asset from there.
Assuming you already have a way of passing in dynamic data, like a Snap Kit app...
You can do it using https://lensstudio.snapchat.com/api/classes/ProceduralTextureProvider/
and passing to your lens the pixel data. You will need to use compression algorithms to pass most images without crashes or performance issues though.
Thanks a lot Brandon / Apoc! That's what I needed. Have been playing with this for a couple days now, but can't find a way to convert the images into Uint8Array that works in LensStudio.
I'm developing in React Native and could get a Uint8Array and inject it to the lens as an Array, but it won't work since the array's length is too short. Tried using the same array on the Web with Blob, and it works like a charm there.
This is how I'm creating the array that will be injected into Lens Studio to render the image:
axios({method: 'get',
url: imageString,
responseType: 'arraybuffer'
})
.then(function (response) {
constuintPic=newUint8Array(response.data)
constarray=Array.from(uintPic)
}
Any idea what might be going wrong?
Updating for future reference.
Found out I can use Jimp, a NodeJS library for image processing that is compatible with React Native (at least for version 0.14.0)
Jimp.read(url,(err,image) => {console.log("🚀 ~ image.bitmap: image.bitmap)
});