create3000 / x_ite

X_ITE X3D Browser, view and manipulate X3D and VRML scenes in HTML.
https://create3000.github.io/x_ite/
Other
66 stars 13 forks source link

Animated GIF aren't animated #132

Closed elcibi closed 1 year ago

elcibi commented 1 year ago

Hi and thanks for this wonderful job!

Unfortunately, I have found an issue with animated gif :

Describe the bug When using an animated gif as "MovieTexture" an error occurs : "Error loading movie: http://.../fire.gif?_=1672934206216.006 error" When used as ImageTexture, only the first frame of the gif is displayed without any animation.

To Reproduce Use any animated gif as texture for MovieTexture (error, not displayed) or ImageTexture (no error, but no animation)

Shape {
  appearance Appearance {
    texture MovieTexture {
      url "transparent-flame-video-5.gif"
    }
  }
  geometry Box {
    size .8 1.5 .001
  }
}

Expected behavior Animated gif should be displayed and animated as movies, but with the benefit of the gif transparency eg. https://jsl-online.com/wp-content/uploads/2019/07/transparent-flame-video-5.gif This animated fire gif applied to a box shape should be transparent and animated :)

create3000 commented 1 year ago

I spend some hours on this issue, now it's finally done. ;) Now, you can use GIFs with MovieTexture. Because it is hard to determine if the GIF is transparent, you must do it manually by setting Appearance.alphaMode to "BLEND" as shown below. Please test the new MovieTexture, and drop me a line if it is working for you.

#X3D V4.0 utf8

PROFILE Interchange

Shape {
  appearance Appearance {
    alphaMode "BLEND"
    texture MovieTexture {
      loop TRUE
      url "transparent-flame-video-5.gif"
    }
  }
  geometry Box {
    size .8 1.5 .001
  }
}
elcibi commented 1 year ago

It works fine, many thanks for this fast enhancement! :)

I've encountered an issue with a two framed gif (light on/light off) which wasn't playing the animation, but simply added a third frame to it and it runs well. Transparency works fine with the alphaMode setting!

Great job! Thanks to you I can dust off some pretty old vrml scripts. You're my hero! :)

create3000 commented 1 year ago

Have fixed frame number determination. Should work better now when GIF has only two frames.

elcibi commented 1 year ago

Works perfectly :) Thanks a lot!