Using CopyFrame() in an array
Hello!
I'm trying to accomplish a delay effect by grabbing a texture each frame and pushing it into an array. Once the array reaches 30 in length, it starts removing the first index in the array, and then is constantly updating each frame! It works exactly as I want, but the problem when I test the lens is that I see the RAM constantly increasing until my Snapchat app eventually quits. Is there a way to solve the RAM issue? Thanks!
Here's the code I used.
// -----JS CODE-----
// @input Asset.Texture texture
// @input Component.Image img
var textureLoop = [];
var event = script.createEvent("UpdateEvent");
event.bind(function (eventData)
{
var tex = script.texture.copyFrame();
textureLoop.push(tex);
if (textureLoop.length > 30)
{
textureLoop.shift();
}
script.img.mainPass.baseTex = textureLoop[0];
});
You could try replacing textureLoop.shift() with manually remaking the array. There's a chance that lens studio just processes .shift() weirdly