Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to display frames in loop to animate gif in awe.js #50

Closed
binita12345 opened this issue Aug 12, 2017 · 4 comments
Closed

How to display frames in loop to animate gif in awe.js #50

binita12345 opened this issue Aug 12, 2017 · 4 comments

Comments

@binita12345
Copy link

if i have 6 image frames
tmp-0
tmp-1
tmp-2
tmp-3
tmp-4
tmp-5

for below gif
sb-butterfly

so, how can i set those frames in loop to flapping for butterfly.

Please give me any solution.

@binita12345 binita12345 changed the title How to set gif frames in loop to animate gif in awe.js How to display frames in loop to animate gif in awe.js Aug 12, 2017
@binita12345
Copy link
Author

binita12345 commented Aug 12, 2017

https://www.opengl.org/discussion_boards/showthread.php/198512-How-make-an-animated-texture-%28OpenGL-DevIL-C-%29

You can't load a single animated texture like this.

What you do is load each frame as a separate texture, then animate it as time passes.

For example, if your .gif had 10 frames, you would load create 10 separate textures and load each frame into each texture. Then, if you wished to animate them at 10 fps, you check the amount of time that has passed. If 0 to 0.1 seconds has passed you display frame 0, if 0.1 to 0.2 seconds has passed you display frame 1, and so on.

Any Demo is available for above solution ?

@awe-media
Copy link
Owner

Feel free to provide a pull request if you'd like to submit some code. Otherwise this is not a bug - this is a feature request so closing.

@awe-media
Copy link
Owner

NOTE: You can also use the projection.update() api to update the texture periodically too. e.g.

var butterfly = awe.projections.view(PROJECTION_ID_HERE);
var i = 1;
b.update({
  position:{ y:1 }, // use a minimal non-zero update here
  animation:{
    duration:0.2, // 5 animation steps are 1/5th of a second
    repeat:5, // play for 1 second total
    persist:0,
    step_callback:function() { 
      i++; if (i>5) { i = 1; } // add time scaling here if the animation is too fast
      b.update({ texture:{ path:i+'.png' } });
    }
  }
});

@binita12345
Copy link
Author

binita12345 commented Aug 14, 2017

thanks for your reply
but i have to trigger update function periodically in my app,
how is it possible? how to trigger that function periodically?
if you have any solution, give me soon reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants