动画GIF作为THREE.js中的纹理 [英] Animated GIF as texture in THREE.js

查看:2004
本文介绍了动画GIF作为THREE.js中的纹理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种在THREE.js中使用GIF动画作为纹理的方法。我目前能够加载纹理(甚至是GIF格式),但它不会播放动画。

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

但我需要将GIF动画作为纹理播放,而不是在Canvas中播放。

But I need to play GIF animation as a texture, not in a Canvas.

推荐答案

你所看到的不是动画GIF作为纹理。您链接的网站使用库将GIF的每个帧渲染为纹理,然后通过更改纹理图像的偏移量来循环显示它们。

What you're seeing isn't an animated GIF as a texture. The sites you linked use libraries to render each individual frame of the GIF as a texture and then cycle through them by changing the offset of the textured image.

查看源代码对于 TextureAnimation 链接,请参阅第157行。这是执行此操作的对象。您可以看到正在运行的动画根本不是GIF:

Look at the source for the TextureAnimation link and see line 157. That is the object that performs this. You can see that the running animation isn't a GIF at all:

http://stemkoski.github.io/Three.js/images/run.png

这篇关于动画GIF作为THREE.js中的纹理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆