I'm looking for a way to use a GIF animation as texture in THREE.js. I am currently able to load a texture (even GIF format), but it doesn't play its animation.
Is there any way to do it? I found some links like these:
https://github.com/JordiRos/GLGif
http://stemkoski.github.io/Three.js/Texture-Animation.html
But I need to play GIF animation as a texture, not in a Canvas.
Unity not support Gif. Save individual frames and make an array of textures.
I think the short answer is no. If you want to use JavaScript, you're most likely alternatives are controlling genuine video or using CSS sprites. The benefit of using CSS sprites is that you end up transferring a single image, and that image has better overall compression than multiple individual images.
You can't. Blender does not support the gif format. Long answer: You would need some other software to convert your gifs to a format that blender understands to be able to import them.
Create a video element, load that element using VideoTexture and add the texture to your mesh.
// Create video and play
let textureVid = document.createElement("video")
textureVid.src = `texture.mp4`; // transform gif to mp4
textureVid.loop = true;
textureVid.play();
// Load video texture
let videoTexture = new THREE.VideoTexture(textureVid);
videoTexture.format = THREE.RGBFormat;
videoTexture.minFilter = THREE.NearestFilter;
videoTexture.maxFilter = THREE.NearestFilter;
videoTexture.generateMipmaps = false;
// Create mesh
var geometry = new THREE.SphereGeometry( 1, 1, 1 );
var material = new THREE.MeshBasicMaterial( { map: videoTexture } );
mesh = new THREE.Mesh( geometry, material );
scene.add(mesh);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With